]>
Commit | Line | Data |
---|---|---|
ed9b544e | 1 | require 'benchmark' |
2 | $:.push File.join(File.dirname(__FILE__), 'lib') | |
3 | require 'redis' | |
4 | ||
5 | times = 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 | 10 | Benchmark.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 | 40 | end |
41 | ||
42 | @r.keys('*').each do |k| | |
43 | @r.delete k | |
57172ffb | 44 | end |