]> git.saurik.com Git - redis.git/blob - client-libraries/ruby/bench.rb
max inline request raised again to 1024*1024*256 bytes
[redis.git] / client-libraries / ruby / bench.rb
1 require 'benchmark'
2 $:.push File.join(File.dirname(__FILE__), 'lib')
3 require 'redis'
4
5 times = 20000
6
7 @r = Redis.new#(:debug => true)
8 @r['foo'] = "The first line we sent to the server is some text"
9
10 Benchmark.bmbm do |x|
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
40 end
41
42 @r.keys('*').each do |k|
43 @r.delete k
44 end