Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update benchmark script

Show elapsed time of the last execution.
  • Loading branch information...
commit b7846971dfdd4d7db60ef7b1a6734adc2f244ea4 1 parent 27166a6
@nahi nahi authored
Showing with 13 additions and 14 deletions.
  1. +13 −14 bench/bench.rb
View
27 bench/bench.rb
@@ -1,18 +1,15 @@
+# encoding: utf-8
require_relative "../lib/rbtree_map"
file = ARGV.shift or raise
def benchmark(&block)
- begin
- start = Time.now
- yield
- finished = Time.now
- ensure
- puts "$B7P2a;~4V(B #{(finished - start) * 1000} [msec]"
- end
+ start = Time.now
+ yield
+ (Time.now - start) *1000
end
-print "$BF0:n3NG'(B..."
+print "動作確認..."
map = RBTreeMap.newInstance
File.open(file).each_line do |line|
key, value, height = line.chomp.split(',', 3)
@@ -21,15 +18,16 @@ def benchmark(&block)
File.open(file).each_line do |line|
key, value, _ = line.split(',', 3)
if map.get(key) != value
- raise "$BCM$NIT0lCW(B #{map.get(key)} != #{value} at line #{line}"
+ raise "値の不一致 #{map.get(key)} != #{value} at line #{line}"
end
end
puts "OK"
-puts "$B%Y%s%A%^!<%/(B..."
-5.times do |idx|
- print "$B%Y%s%A%^!<%/(B #{idx + 1} $B2sL\(B: "
- benchmark do
+times = 5
+puts "ウォームアップ... (#{times} 回)"
+(times + 1).times do |idx|
+ puts "ベンチマーク: " if idx == times
+ elapsed = benchmark {
map = RBTreeMap.newInstance
File.open(file).each_line do |line|
key, value, height = line.chomp.split(',', 3)
@@ -41,5 +39,6 @@ def benchmark(&block)
puts "wrong value! #{map.get(key)} != #{value}"
end
end
- end
+ }
+ puts elapsed
end
Please sign in to comment.
Something went wrong with that request. Please try again.