Skip to content

Instantly share code, notes, and snippets.

@lukemelia
Forked from brynary/gist:83366
Created March 23, 2009 01:41
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 lukemelia/83377 to your computer and use it in GitHub Desktop.
Save lukemelia/83377 to your computer and use it in GitHub Desktop.
require "benchmark"
x = 10_000
first_id = Sport.first.id
key = "Sport:#{first_id}"
Sport.set key, Sport.find(first_id) # prime cache
Benchmark.bm(20) do |b|
b.report "Sport.get" do
x.times do
Sport.get key
end
end
end
# weplay1 user system total real
# Sport.get 17.420000 0.350000 17.770000 ( 24.056716)
#
# weplay2 user system total real
# Sport.get 18.440000 0.490000 18.930000 ( 23.156452)
#
# weplay3 user system total real
# Sport.get 19.640000 0.540000 20.180000 ( 25.612381)
#
# weplay4 user system total real
# Sport.get 18.420000 0.470000 18.890000 ( 28.232393)
#
# weplay5 user system total real
# Sport.get 19.220000 0.490000 19.710000 ( 25.920724)
#
# weplay6 user system total real
# Sport.get 16.710000 0.480000 17.190000 ( 41.580876)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment