[Groonga-commit] droonga/droonga-engine at bad290c [master] Add benchmark script for Coolio::TimerWatcher.

Back to archive index

YUKI Hiroshi null+****@clear*****
Tue Apr 7 14:07:03 JST 2015


YUKI Hiroshi	2015-04-07 14:07:03 +0900 (Tue, 07 Apr 2015)

  New Revision: bad290c21a1477f3ec492526d7e3f600c584e112
  https://github.com/droonga/droonga-engine/commit/bad290c21a1477f3ec492526d7e3f600c584e112

  Message:
    Add benchmark script for Coolio::TimerWatcher.
    
    Benchmark result:
    1.0836857050000002 seconds for 100000 timers
    on a development PC (real world)
    
    It is confirmed that overheads for each timer are very small.
    This is a good reason to introduce timeout feature based on TimerWatcher
    for every messages.

  Added files:
    benchmark/timer-watcher/benchmark.rb

  Added: benchmark/timer-watcher/benchmark.rb (+44 -0) 100644
===================================================================
--- /dev/null
+++ benchmark/timer-watcher/benchmark.rb    2015-04-07 14:07:03 +0900 (3f492ee)
@@ -0,0 +1,44 @@
+require "coolio"
+
+$times = 100000
+
+def add_timeout_timer(loop)
+  timeout_timer = Coolio::TimerWatcher.new(60)
+  timeout_timer.on_timer do
+    timeout_timer.detach
+    timeout_timer = nil
+  end
+  loop.attach(timeout_timer)
+  timeout_timer
+end
+
+puts "start."
+
+$start = Time.now
+$timers = []
+$loop = Cool.io::Loop.default
+$times.times do
+  $timers << add_timeout_timer($loop)
+end
+
+$timeout_before = Time.now
+timeout_timer = Coolio::TimerWatcher.new(1)
+timeout_timer.on_timer do
+  $timeout_after = Time.now
+
+  timeout_timer.detach
+  $timers.each do |timer|
+    timer.detach
+  end
+
+  $finish = Time.now
+  delta = $finish - $start
+  delta -= $timeout_after - $timeout_before
+  puts "done."
+  puts "overhead: #{delta} seconds for #{$times} timers."
+end
+$loop.attach(timeout_timer)
+
+$loop.run
+
+
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index