Last active
September 3, 2015 01:42
-
-
Save maceto/b8409e7aad3c767426a6 to your computer and use it in GitHub Desktop.
Benchmark on MongoDB with ORM MongoID
This file contains 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/ips' | |
# Counting of records with ORM or directly on MongoDB | |
# | |
# IncomingCall.where(:created_at.gte =>(Date.today-30)).count | |
# | |
# VS | |
# | |
# db[:incoming_calls].aggregate([ | |
# { "$match": { created_at: {"$gte": (Date.today-30)} } }, | |
# { "$group":{ _id: "$incoming_call_id", "count": {"$sum":1}} } | |
# ]) | |
ips | { |x| x.report("directo"){db[:incoming_calls].aggregate([ { "$match": { created_at: {"$gte": (Date.today-30)} } },{ "$group":{ _id: "$incoming_call_id", "count": {"$sum":1}} } ])};x.report("ORM"){ IncomingCall.where(:created_at.gte =>(Date.today-30)).count };x.compare!} | |
Calculating ------------------------------------- | |
directo 153.000 i/100ms | |
ORM 143.000 i/100ms | |
------------------------------------------------- | |
directo 1.527k (± 4.1%) i/s - 7.650k | |
ORM 1.348k (±11.4%) i/s - 6.721k | |
Comparison: | |
directo: 1526.6 i/s | |
ORM: 1348.1 i/s - 1.13x slower | |
# | |
# END | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment