Fixed benchmark test. Added find_first benchmark.

This commit is contained in:
Jim Menard 2009-02-10 10:43:47 -05:00
parent 9a7ed4c3d3
commit 65282a2f7e

View File

@ -1,4 +1,3 @@
require "rubygems"
require "benchmark" require "benchmark"
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib') $LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
@ -17,7 +16,7 @@ TEST_COUNT = 100
puts "Generating benchmark data" puts "Generating benchmark data"
msgs = %w{hola hello aloha ciao} msgs = %w{hola hello aloha ciao}
arr = OBJS_COUNT.times.map {|x| { :number => x, :rndm => (rand(5)+1), :msg => msgs[rand(4)] }} arr = (0..OBJS_COUNT).collect {|x| { :number => x, :rndm => (rand(5)+1), :msg => msgs[rand(4)] }}
puts "Running benchmark" puts "Running benchmark"
Benchmark.bmbm do |results| Benchmark.bmbm do |results|
@ -33,6 +32,11 @@ Benchmark.bmbm do |results|
coll.insert(arr) coll.insert(arr)
} }
} }
results.report("find_first: ") {
TEST_COUNT.times {
coll.find_first(:number => 0)
}
}
end end
coll.clear coll.clear