Created
April 14, 2011 21:44
-
-
Save banker/920630 to your computer and use it in GitHub Desktop.
Simple Mongoid Benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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