Skip to content

Instantly share code, notes, and snippets.

@jgonera
Created October 21, 2011 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgonera/1303536 to your computer and use it in GitHub Desktop.
Save jgonera/1303536 to your computer and use it in GitHub Desktop.
Mongo driver vs. Mongoid benchmark
require 'benchmark'
require 'mongo'
require 'mongoid'
require './project'
db = Mongo::Connection.new.db('coledit_development')
Mongoid.configure do |config|
config.master = db
end
Benchmark.bm(7) do |bm|
bm.report('driver') do
10000.times do
project = db['projects'].find(:_id=>BSON::ObjectId('4e52ccbd3a5c9f20b8000003'))
project.each { |p| p }
end
end
bm.report('mongoid') do
10000.times do
project = Project.find('4e52ccbd3a5c9f20b8000003')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment