Skip to content

Commit

Permalink
Allow to select I/O mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
avsej committed Mar 20, 2012
1 parent f85fc1b commit cc31edc
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion run.rb
Expand Up @@ -36,7 +36,8 @@
:prefix => 'em-couchbase:',
:size => 256,
:slice => 1_000,
:tick => 1
:tick => 1,
:mechanism => :select
}

LOGGER = Logger.new(STDOUT)
Expand All @@ -48,6 +49,9 @@

OptionParser.new do |opts|
opts.banner = "Usage: #{__FILE__} [options]"
opts.on("-m", "--mechanism MECH", "The mechanism for multiplexing I/O. EventMachine supports (:select, :epoll, :kqueue) (default: #{options[:mechanism].inspect})") do |v|
options[:mechanism] = v.to_sym
end
opts.on("-t", "--tick SECONDS", "The interval for timer (default: #{options[:tick].inspect})") do |v|
options[:tick] = v.to_i
end
Expand Down Expand Up @@ -95,6 +99,15 @@
ops_per_fork = (options[:operations] / options[:concurrency].to_f).ceil
forks = []

case options[:mechanism]
when :epoll
EM.epoll = true
when :kqueue
EM.kqueue = true
else
# select
end

options[:concurrency].times do |n|
forks << fork do
$0 = "#{__FILE__}: fork ##{n}"
Expand Down

0 comments on commit cc31edc

Please sign in to comment.