forked from voloko/redis-model
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbench.rb
More file actions
36 lines (30 loc) · 665 Bytes
/
bench.rb
File metadata and controls
36 lines (30 loc) · 665 Bytes
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
require 'rubygems'
require 'benchmark'
$:.push File.join(File.dirname(__FILE__), 'lib')
require 'redis/model'
n = 20000
class TestModel < Redis::Model
value :foo
list :bar
end
@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 (model)") do
n.times do |i|
m = TestModel.with_key(i)
m.foo = "The first line we sent to the server is some text";
m.foo
end
end
x.report("push+trim (model)") do
n.times do |i|
m = TestModel.with_key(i)
m.bar << i
m.bar.trim 0, 30
end
end
end
@r.keys('*').each do |k|
@r.delete k
end