class Roma::Client::Microbench

Attributes

cnt[R]
runnable[R]
sleep_time_watcher[R]
tmax[R]
tmin[R]
watcher[R]

Public Class Methods

new() click to toggle source
   # File lib/roma/tools/simple_bench2.rb
15 def initialize
16   @cnt = 0
17   @tmax = 0
18   @tmin = 100
19   @runnable = true
20   @sleep_time_watcher = 10
21   init_watcher
22 end

Public Instance Methods

send_random_requests_loop(addr, port) click to toggle source
   # File lib/roma/tools/simple_bench2.rb
37 def send_random_requests_loop addr, port
38 end
send_read_requests(addr, port, count) click to toggle source
   # File lib/roma/tools/simple_bench2.rb
40 def send_read_requests addr, port, count
41   rc = Roma::Client::RomaClient.new("#{addr}:#{port.to_s}")
42   count.times { |c|
43     i = rand count
44     ts = DateTime.now
45     res = rc.get(i.to_s)
46     puts "get k=#{i} #{res}" if res == :error
47   }
48 end

Private Instance Methods

init_watcher() click to toggle source
   # File lib/roma/tools/simple_bench2.rb
24 def init_watcher
25   @watcher = Thread.new {
26     while @runnable
27       sleep @sleep_time_watcher
28       printf("qps=%d max=%f min=%f ave=%f\n",@@cnt/sleep_time,@@tmax,@@tmin,sleep_time/@@cnt.to_f)
29       @cnt = 0
30       @tmax = 0
31       @tmin = 100
32     end
33   }
34 end