2009-03-22 05:30:00 -04:00
|
|
|
require 'benchmark'
|
|
|
|
$:.push File.join(File.dirname(__FILE__), 'lib')
|
|
|
|
require 'redis'
|
|
|
|
|
|
|
|
times = 20000
|
|
|
|
|
2009-05-09 03:25:59 -04:00
|
|
|
@r = Redis.new#(:debug => true)
|
2009-03-22 05:30:00 -04:00
|
|
|
@r['foo'] = "The first line we sent to the server is some text"
|
2009-05-09 03:25:59 -04:00
|
|
|
|
2009-03-22 05:30:00 -04:00
|
|
|
Benchmark.bmbm do |x|
|
2009-05-09 03:25:59 -04:00
|
|
|
x.report("set") do
|
|
|
|
20000.times do |i|
|
|
|
|
@r["set#{i}"] = "The first line we sent to the server is some text"; @r["foo#{i}"]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
x.report("set (pipelined)") do
|
|
|
|
@r.pipelined do |pipeline|
|
|
|
|
20000.times do |i|
|
|
|
|
pipeline["set_pipelined#{i}"] = "The first line we sent to the server is some text"; @r["foo#{i}"]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
x.report("push+trim") do
|
|
|
|
20000.times do |i|
|
|
|
|
@r.push_head "push_trim#{i}", i
|
|
|
|
@r.list_trim "push_trim#{i}", 0, 30
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
x.report("push+trim (pipelined)") do
|
|
|
|
@r.pipelined do |pipeline|
|
|
|
|
20000.times do |i|
|
|
|
|
pipeline.push_head "push_trim_pipelined#{i}", i
|
|
|
|
pipeline.list_trim "push_trim_pipelined#{i}", 0, 30
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2009-03-22 05:30:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
@r.keys('*').each do |k|
|
|
|
|
@r.delete k
|
2009-05-09 03:25:59 -04:00
|
|
|
end
|