Skip to content

Instantly share code, notes, and snippets.

@bpoweski
Created August 6, 2011 21:29
Show Gist options
  • Save bpoweski/1129768 to your computer and use it in GitHub Desktop.
Save bpoweski/1129768 to your computer and use it in GitHub Desktop.
Benchmark
require "benchmark"
require "mongoid"
require "./perf/models"
Mongoid.configure do |config|
config.master = Mongo::Connection.new.db("mongoid_perf_test")
end
Mongoid.master.collections.select {|c| c.name !~ /system/ }.each(&:drop)
puts "Creating indexes..."
[ Person, Post, Game, Preference ].each(&:create_indexes)
puts "Starting benchmark..."
Benchmark.bm do |bm|
puts "\n[ Root Document Benchmarks ]"
[ 1000, 10000, 100000, 1000000 ].each do |i|
Mongoid.unit_of_work do
puts "[ #{i} ]"
bm.report("#new ") do
i.times do |n|
Person.new
end
end
end
end
end
# 1.9.2 p180
Creating indexes...
Starting benchmark...
user system total real
[ Root Document Benchmarks ]
[ 1000 ]
#new 0.090000 0.000000 0.090000 ( 0.094167)
[ 10000 ]
#new 0.930000 0.000000 0.930000 ( 0.932674)
[ 100000 ]
#new 9.400000 0.030000 9.430000 ( 9.608434)
[ 1000000 ]
#new 93.440000 0.250000 93.690000 ( 94.889635)
# REE 2011.03
Creating indexes...
Starting benchmark...
user system total real
[ Root Document Benchmarks ]
[ 1000 ]
#new 0.080000 0.000000 0.080000 ( 0.084479)
[ 10000 ]
#new 1.060000 0.040000 1.100000 ( 1.099856)
[ 100000 ]
#new 10.430000 0.380000 10.810000 ( 11.031532)
[ 1000000 ]
#new 104.220000 3.770000 107.990000 (109.554233)
# 1.9.3.preview1
Creating indexes...
Starting benchmark...
user system total real
[ Root Document Benchmarks ]
[ 1000 ]
#new 0.080000 0.000000 0.080000 ( 0.084575)
[ 10000 ]
#new 0.850000 0.010000 0.860000 ( 0.860616)
[ 100000 ]
#new 8.620000 0.010000 8.630000 ( 8.637046)
[ 1000000 ]
#new 86.470000 0.180000 86.650000 ( 87.349074)
# jruby-1.6.2
Creating indexes...
Starting benchmark...
user system total real
[ Root Document Benchmarks ]
[ 1000 ]
#new 0.767000 0.000000 0.767000 ( 0.767000)
[ 10000 ]
#new 3.646000 0.000000 3.646000 ( 3.646000)
[ 100000 ]
#new 15.054000 0.000000 15.054000 ( 15.054000)
[ 1000000 ]
#new 142.024000 0.000000 142.024000 (142.024000)
# rbx-head
Creating indexes...
Starting benchmark...
user system total real
[ Root Document Benchmarks ]
[ 1000 ]
#new 0.131273 0.001299 0.132572 ( 0.280259)
[ 10000 ]
#new 1.382158 0.014398 1.396556 ( 2.560097)
[ 100000 ]
#new 13.029592 0.070919 13.100511 ( 20.573260)
[ 1000000 ]
#new 147.408825 0.482304 147.891129 (192.847959)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment