Permalink
Browse files

Allow to select I/O mechanism

  • Loading branch information...
1 parent f85fc1b commit cc31edc223b5fbb5dea64edf0b701f356b291686 @avsej committed Mar 20, 2012
Showing with 14 additions and 1 deletion.
  1. +14 −1 run.rb
View
15 run.rb
@@ -36,7 +36,8 @@
:prefix => 'em-couchbase:',
:size => 256,
:slice => 1_000,
- :tick => 1
+ :tick => 1,
+ :mechanism => :select
}
LOGGER = Logger.new(STDOUT)
@@ -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
@@ -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}"

0 comments on commit cc31edc

Please sign in to comment.