Sha256: 4d6c3949f6ca3d7cca354bcc7929acfd2d03b7464269f248510a72284c2d5faf
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 KB
Contents
require 'benchmark' require "#{File.dirname(__FILE__)}/../lib/lawnchair" Lawnchair.connectdb Lawnchair.flushdb # Totally contrived and fairly useless example... just wanted to make sure the overhead of # reading and marshalling the data isn't obscene # *** Performing 1000 iterations *** # user system total real # cached: 0.140000 0.040000 0.180000 ( 0.292324) # not cached: 26.070000 0.620000 26.690000 ( 27.156388) n = (ARGV.shift || 1000).to_i puts "*** Performing #{n} iterations ***" def expensive_stuff a = [] 100.times do a << Date.parse("Dec 3. 1981") end end Benchmark.bm(7) do |x| x.report("cached:\t\t") do (1..n).each do |i| Lawnchair::Cache.me(:key => "redis_cache") do expensive_stuff end end end x.report("in process cached:") do (1..n).each do |i| Lawnchair::Cache.me(:key => "in_process_cache") do expensive_stuff end end end x.report("not cached:\t\t") do (1..n).each do |i| expensive_stuff end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
lawnchair-0.5.1 | spec/speed.rb |
lawnchair-0.5.0 | spec/speed.rb |
lawnchair-0.3.2 | spec/speed.rb |
lawnchair-0.4.0 | spec/speed.rb |