public
Description: A ruby client library for the redis key value storage engine
Homepage:
Clone URL: git://github.com/ezmobius/redis-rb.git
ezmobius (author)
Wed Nov 04 13:52:57 -0800 2009
commit  4c07ac06e94e628ad3ce16dde6729c6ca418bc62
tree    2d214549958bd004627e9ad6595bb0586cedfcc5
parent  edfb1f6d135d4af03b43b896508e0f08842020fb
redis-rb / bench.rb
100644 44 lines (37 sloc) 1.022 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'benchmark'
$:.push File.join(File.dirname(__FILE__), 'lib')
require 'redis'
 
times = 20000
 
@r = Redis.new#(:debug => true)
@r['foo'] = "The first line we sent to the server is some text"
 
Benchmark.bmbm do |x|
  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
end
 
@r.keys('*').each do |k|
  @r.delete k
end