Skip to content

Instantly share code, notes, and snippets.

@boriscy
Last active August 29, 2015 14:16
Show Gist options
  • Save boriscy/f0204bbc2218c43a1195 to your computer and use it in GitHub Desktop.
Save boriscy/f0204bbc2218c43a1195 to your computer and use it in GitHub Desktop.
Compare mongoHQ in heroku
require 'benchmark'
# 10 records
apis = ["42-507-32941", "42-507-32942", "42-507-32943", "42-507-32944", "42-507-32945", "42-507-32950", "42-507-32956", "42-501-35879", "42-507-32908", "42-507-32909"]
Benchmark.measure { WellIndex::Core.where(:api => apis).all }
# <Benchmark::Tms:0x0000000b156a48
# @real=0.481202381, # This
# @stime=0.0,
# @total=0.009999999999999787,
# @utime=0.009999999999999787>
Benchmark.measure { apis.each { |api| WellIndex::Core.find_by_api(api) } }
#<Benchmark::Tms:0x0000000b202410
# @real=1.97555423, # This
# @stime=0.0,
# @total=0.019999999999999574,
# @utime=0.019999999999999574>
# 50 records
apis = ["42-507-32941", "42-507-32942", "42-507-32943", "42-507-32944", "42-507-32945", "42-507-32950", "42-507-32956", "42-501-35879", "42-507-32908", "42-507-32909", "42-507-32910", "42-507-32911", "42-507-32912", "42-507-32913", "42-507-32914", "42-507-32916", "42-507-32917", "42-507-32918", "42-507-32919", "42-507-32920", "42-507-32921", "42-507-32922", "42-507-32923", "42-507-32924", "42-507-32925", "42-507-32926", "42-507-32927", "42-507-32928", "42-507-32929", "42-507-32930", "42-507-32931", "42-507-32932", "42-507-32934", "42-507-32935", "42-507-32936", "42-507-32937", "42-507-32938", "42-507-32939", "42-507-32940", "42-501-35878", "42-507-32775", "42-507-32776", "42-507-32777", "42-507-32778", "42-507-32779", "42-507-32780", "42-507-32781", "42-507-32782", "42-507-32783", "42-507-32784"]
Benchmark.measure { WellIndex::Core.where(:api => apis).all }
#<Benchmark::Tms:0x00000009efb3a8
# @real=0.790311003, # This
# @stime=0.0,
# @total=0.10999999999999943,
# @utime=0.10999999999999943>
Benchmark.measure { apis.each { |api| WellIndex::Core.find_by_api(api) } }
#<Benchmark::Tms:0x0000000b0ae460
# @real=9.604038202, # This
# @stime=0.010000000000000009,
# @total=0.09000000000000008,
# @utime=0.08000000000000007>
# Using uwis in States::Colorado::Core
uwis = %w(8400512323461 8400512323462 8400512323463 8400512323464 8400504511663 8400504511664 8400504511665 8400504511666 8400504511667 8400512323467 8400501306522 8400504511668 8400504511669 8400504511670 8400504511671 8400504511672 8400504511673 8400510310665 8400510310666 8400512323465 8400512323466 8400504511675 8400504511676 8400504511677 8400504511678 8400512324138 8400506709227 8400506709226 8400507108915 8400507108914 8400507108913 8400512324096 8400504515432 8400500906652 8400512325397 8400504515422 8400504515423 8400504515424 8400504515425 8400504515426 8400504515427 8400504515428 8400504515429 8400504515430 8400504515431 8400501306571 8400506709488 8400506709489 8400512325398 8400512325399)
Benchmark.measure { States::Colorado::Core.where(:uwi => uwis).all }
#<Benchmark::Tms:0x00000009f4b6c8
# @real=0.654079946,
# @stime=0.0,
# @total=0.129999999999999,
# @utime=0.129999999999999>
# HEROKU @real=0.013755525
Benchmark.measure { uwis.each { |uwi| States::Colorado::Core.find_by_uwi(uwi) } }
#<Benchmark::Tms:0x0000000b1a2f60
# @real=10.217551882,
# @stime=0.0,
# @total=0.08000000000000007,
# @utime=0.08000000000000007>
# HEROKU @real=0.087476694
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment