Skip to content

Instantly share code, notes, and snippets.

@tjsingleton
Created February 15, 2013 20:58
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 tjsingleton/4963489 to your computer and use it in GitHub Desktop.
Save tjsingleton/4963489 to your computer and use it in GitHub Desktop.
require 'benchmark/ips'
require_relative '../config/environment'
Benchmark.ips do |x|
x.report("without patch - by slug") {
User.uncached do
User.find("tj-singleton")
end
}
x.report("without patch - by id") {
User.uncached do
User.find("1")
end
}
end
Calculating -------------------------------------
with patch - by slug 82 i/100ms
with patch - by id 97 i/100ms
-------------------------------------------------
with patch - by slug 999.0 (±27.9%) i/s - 4428 in 5.059986s
with patch - by id 1112.1 (±30.2%) i/s - 4947 in 5.114582s
Calculating -------------------------------------
without patch - by slug
56 i/100ms
without patch - by id
32 i/100ms
-------------------------------------------------
without patch - by slug
672.1 (±29.9%) i/s - 3024 in 5.105228s
without patch - by id
358.0 (±30.4%) i/s - 1536 in 5.004642s
@rogthefrog
Copy link

Niiiiiiice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment