Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Comparison of mappers

View verdict.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
require "benchmark"
 
require "mongo_mapper"
require "mongoid"
 
class MongoMapperModel
include MongoMapper::Document
key :title, String
key :content, String
key :published_at, Time
end
 
MongoMapper.connection = Mongo::Connection.new("127.0.0.1", 27017)
MongoMapper.database = "mongo_mapper_verdict"
 
MongoMapperModel.delete_all
 
class MongoidModel
include Mongoid::Document
field :title, type: String
field :content, type: String
field :published_at, type: Time
end
 
Mongoid.configure do |c|
c.connect_to("mongoid_verdict")
end
 
MongoidModel.delete_all
 
Benchmark.bm do |bench|
 
bench.report("MongoMapper create") do
100_000.times do |n|
MongoMapperModel.create(title: "#{n}", content: "#{n}", published_at: Time.now)
end
end
 
bench.report("Mongoid create") do
100_000.times do |n|
MongoidModel.create(title: "#{n}", content: "#{n}", published_at: Time.now)
end
end
 
# MongoMapper create 50.240000 1.330000 51.570000 ( 51.575320)
# Mongoid create 34.430000 1.130000 35.560000 ( 35.554373)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.