Permalink
Browse files

Update benchmark scripts

  • Loading branch information...
1 parent b0edf46 commit 386272c0c1fe3d72f27b6ea40b03f6f10c985c36 @nahi committed Feb 5, 2012
Showing with 18 additions and 15 deletions.
  1. +2 −0 bench/bench.rb
  2. +11 −10 bench/bench_element_size.rb
  3. +5 −5 bench/profile.rb
View
@@ -1,6 +1,7 @@
require 'benchmark'
require 'radix_tree' # gem install radix_tree
require 'avl_tree'
+require 'red_black_tree'
require 'openssl'
#random = Random.new(0)
@@ -48,4 +49,5 @@ def run(bm, h, keys)
run(bm, Hash.new, keys)
run(bm, RadixTree.new, keys)
run(bm, AVLTree.new, keys)
+ run(bm, RedBlackTree.new, keys)
end
@@ -1,8 +1,7 @@
require 'benchmark'
require 'radix_tree' # gem install radix_tree
require 'avl_tree'
-
-random = Random.new(0)
+require 'openssl'
times = 100000
key_size = 10
@@ -38,15 +37,17 @@ def run(bm, h, keys)
end
end
-[10000, 20000, 50000, 100000, 200000, 500000].each do |elements|
- keys = []
- elements.times do
- keys << random.bytes(key_size)
- end
+keys = []
+1000000.times do
+ keys << OpenSSL::Random.random_bytes(key_size)
+end
+
+1.upto(100) do |idx|
+ elements = idx * 10000
Benchmark.bm(30) do |bm|
- run(bm, Hash.new, keys)
- run(bm, RadixTree.new, keys)
- run(bm, AVLTree.new, keys)
+ #run(bm, Hash.new, keys[0, elements])
+ #run(bm, RadixTree.new, keys)
+ run(bm, AVLTree.new, keys[0, elements])
end
end
View
@@ -1,13 +1,13 @@
-require File.expand_path('../lib/avl_tree', File.dirname(__FILE__))
+require File.expand_path('../lib/red_black_tree', File.dirname(__FILE__))
random = Random.new(0)
-TIMES = 200000
+TIMES = 50000
key_size = 10
-h = AVLTree.new
+h = RedBlackTree.new
TIMES.times do
h[random.bytes(key_size)] = 1
- h[random.bytes(key_size)]
- h.delete(random.bytes(key_size))
+ #h[random.bytes(key_size)]
+ #h.delete(random.bytes(key_size))
end

0 comments on commit 386272c

Please sign in to comment.