Sha256: 490a0ac230b7e90b4dfc964ecab9647ae346c514b83f7463ba5f2d996c9fd5a1

Contents?: true

Size: 1020 Bytes

Versions: 15

Compression:

Stored size: 1020 Bytes

Contents

require "benchmark"
  
$LOAD_PATH[0,0] = File.join(File.dirname(__FILE__), '..', 'lib')
require 'mongo'

host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost'
port = ENV['MONGO_RUBY_DRIVER_PORT'] || XGen::Mongo::Driver::Mongo::DEFAULT_PORT

puts "Connecting to #{host}:#{port}"
db = XGen::Mongo::Driver::Mongo.new(host, port).db('ruby-mongo-examples')
coll = db.collection('test')
coll.clear

OBJS_COUNT = 100
TEST_COUNT = 100

puts "Generating benchmark data"
msgs = %w{hola hello aloha ciao}
arr = (0..OBJS_COUNT).collect {|x| { :number => x, :rndm => (rand(5)+1), :msg => msgs[rand(4)] }}

puts "Running benchmark"
Benchmark.bmbm do |results|
  results.report("single object inserts:  ") { 
    TEST_COUNT.times {
      coll.clear
      arr.each {|x| coll.insert(x)} 
    }
  }
  results.report("multiple object insert: ") { 
    TEST_COUNT.times {
      coll.clear
      coll.insert(arr)
    }
  }
  results.report("find_first: ") {
    TEST_COUNT.times {
      coll.find_first(:number => 0)
    }
  }
end

coll.clear

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
animehunter-mongo-0.9 examples/benchmarks.rb
mongodb-mongo-0.10.1 examples/benchmarks.rb
mongodb-mongo-0.10 examples/benchmarks.rb
mongodb-mongo-0.11.1 examples/benchmarks.rb
mongodb-mongo-0.11 examples/benchmarks.rb
mongodb-mongo-0.6.1 examples/benchmarks.rb
mongodb-mongo-0.6.2 examples/benchmarks.rb
mongodb-mongo-0.6.3 examples/benchmarks.rb
mongodb-mongo-0.6.4 examples/benchmarks.rb
mongodb-mongo-0.6.5 examples/benchmarks.rb
mongodb-mongo-0.6.6 examples/benchmarks.rb
mongodb-mongo-0.6.7 examples/benchmarks.rb
mongodb-mongo-0.7 examples/benchmarks.rb
mongodb-mongo-0.8 examples/benchmarks.rb
mongodb-mongo-0.9 examples/benchmarks.rb