Last active
December 18, 2015 18:30
-
-
Save afeld/5826497 to your computer and use it in GitHub Desktop.
performance comparison of Mongoid, Moped and `mongo` shell w/ MongoDB 2.4.3
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
function bench(f) { | |
var start = new Date(); | |
f(); | |
var finish = new Date(); | |
print( ((finish-start) / 1000) + 's' ); | |
} | |
bench(function(){ | |
db.users.find().limit(2000).forEach(function(user){ | |
}); | |
}); | |
// 2.859s |
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 'benchmark' | |
num_records = 2000 | |
# Mongoid | |
puts Benchmark.measure { | |
User.limit(num_records).each do |user| | |
end | |
} | |
# 0.510000 0.070000 0.580000 ( 0.665689) | |
# Moped | |
puts Benchmark.measure { | |
User.collection.find().limit(num_records).each do |user| | |
end | |
} | |
# 0.480000 0.030000 0.510000 ( 0.555456) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If the first is running in the shell it's copying the data over as well from server to client.