]> git.saurik.com Git - redis.git/blame - client-libraries/ruby/bench.rb
CPP client added thanks to Brian Hammond
[redis.git] / client-libraries / ruby / bench.rb
CommitLineData
ed9b544e 1require 'benchmark'
2$:.push File.join(File.dirname(__FILE__), 'lib')
3require 'redis'
4
5times = 20000
6
57172ffb 7@r = Redis.new#(:debug => true)
ed9b544e 8@r['foo'] = "The first line we sent to the server is some text"
57172ffb 9
ed9b544e 10Benchmark.bmbm do |x|
57172ffb 11 x.report("set") do
12 20000.times do |i|
13 @r["set#{i}"] = "The first line we sent to the server is some text"; @r["foo#{i}"]
14 end
15 end
16
17 x.report("set (pipelined)") do
18 @r.pipelined do |pipeline|
19 20000.times do |i|
20 pipeline["set_pipelined#{i}"] = "The first line we sent to the server is some text"; @r["foo#{i}"]
21 end
22 end
23 end
24
25 x.report("push+trim") do
26 20000.times do |i|
27 @r.push_head "push_trim#{i}", i
28 @r.list_trim "push_trim#{i}", 0, 30
29 end
30 end
31
32 x.report("push+trim (pipelined)") do
33 @r.pipelined do |pipeline|
34 20000.times do |i|
35 pipeline.push_head "push_trim_pipelined#{i}", i
36 pipeline.list_trim "push_trim_pipelined#{i}", 0, 30
37 end
38 end
39 end
ed9b544e 40end
41
42@r.keys('*').each do |k|
43 @r.delete k
57172ffb 44end