Skip to content

Instantly share code, notes, and snippets.

@banker
Created April 14, 2011 21:44
Show Gist options
  • Save banker/920630 to your computer and use it in GitHub Desktop.
Save banker/920630 to your computer and use it in GitHub Desktop.
Simple Mongoid Benchmark
require 'rubygems'
require 'mongoid'
Mongoid.configure do |config|
config.master = Mongo::Connection.new['foo']
end
class Item
include Mongoid::Document
field :name, :type => String
end
TRIALS = 10000
t1 = Time.now
TRIALS.times do
Item.create(:name => "Foo")
end
total = Time.now - t1
puts "Time: #{total} Inserts per second: #{TRIALS / total}"
require 'rubygems'
require 'mongo'
c = Mongo::Connection.new
coll = c['test']['foo']
TRIALS = 10000
t1 = Time.now
TRIALS.times do
coll.insert({:name => "Foo"})
end
total = Time.now - t1
puts "#{total} #{TRIALS / total}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment