Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 105 lines (97 sloc) 3.827 kB
9a10007 @flyerhzm add benchmark
flyerhzm authored
1 require 'benchmark'
2
3 JRUBY = defined?(JRUBY_VERSION)
4
30fb4a4 @flyerhzm pure java implementation
flyerhzm authored
5 require 'rubygems'
9a10007 @flyerhzm add benchmark
flyerhzm authored
6 if JRUBY
7 require 'lib/memcached'
30fb4a4 @flyerhzm pure java implementation
flyerhzm authored
8 require 'jruby-spymemcached'
9a10007 @flyerhzm add benchmark
flyerhzm authored
9 else
10 require 'memcached'
11 end
12 require 'dalli'
13
14 memcached = Memcached.new(['localhost:11211'])
30fb4a4 @flyerhzm pure java implementation
flyerhzm authored
15 spymemcached = Spymemcached.new(['localhost:11211']) if JRUBY
9a10007 @flyerhzm add benchmark
flyerhzm authored
16 dalli = Dalli::Client.new(['localhost:11211'])
17
18 3.to_i.times {
19 Benchmark.bm(30) {|bm|
20 if JRUBY
21 bm.report("jruby-memcached set") {
2c9b94e @flyerhzm set method should not be async
flyerhzm authored
22 100_000.times { memcached.set('foo', 'bar') }
9a10007 @flyerhzm add benchmark
flyerhzm authored
23 }
24 bm.report("jruby-memcached get") {
25 100_000.times { memcached.get('foo') }
26 }
30fb4a4 @flyerhzm pure java implementation
flyerhzm authored
27 bm.report("jruby-spymemcached set") {
28 100_000.times { spymemcached.set('foo', 'bar') }
29 }
30 bm.report("jruby-spymemcached get") {
31 100_000.times { spymemcached.get('foo') }
32 }
9a10007 @flyerhzm add benchmark
flyerhzm authored
33 else
34 bm.report("memcached set") {
35 100_000.times { memcached.set('foo', 'bar') }
36 }
37 bm.report("memcached get") {
38 100_000.times { memcached.get('foo') }
39 }
40 end
41 }
42 }
43
44 3.times {
45 Benchmark.bm(30) {|bm|
46 bm.report("dalli set") {
47 100_000.times { dalli.set('foo', 'bar') }
48 }
49 bm.report("dalli get") {
50 100_000.times { dalli.get('foo') }
51 }
52 }
53 }
54
bdec39f @flyerhzm memcached.quit in benchmark.rb
flyerhzm authored
55 memcached.quit
56 spymemcached.shutdown if JRUBY
9a10007 @flyerhzm add benchmark
flyerhzm authored
57 dalli.close
58
d2d783d @flyerhzm Bumping version to 0.3.0
flyerhzm authored
59 # I run benchmark for each client 3 times, but only list the last result for each.
60 #
491f780 @flyerhzm add benchmark for 0.3.0
flyerhzm authored
61 # MBP 2.8G i7 jruby-memcached 0.3.0
9a10007 @flyerhzm add benchmark
flyerhzm authored
62 #
63 # ruby-1.9.3-p194
64 # ruby benchmark.rb
65 # user system total real
66 # memcached set 1.110000 1.020000 2.130000 ( 4.592509)
67 # memcached get 0.970000 1.000000 1.970000 ( 4.172170)
68 # user system total real
491f780 @flyerhzm add benchmark for 0.3.0
flyerhzm authored
69 # dalli set 8.360000 1.650000 10.010000 ( 10.193101)
70 # dalli get 8.040000 1.670000 9.710000 ( 9.828392)
71 #
72 # jruby-1.6.7.2
73 # jruby --server -Ilib -S benchmark.rb
74 # user system total real
75 # jruby-memcached set 5.842000 0.000000 5.842000 ( 5.842000)
76 # jruby-memcached get 5.561000 0.000000 5.561000 ( 5.561000)
77 # user system total real
78 # jruby-spymemcached set 5.919000 0.000000 5.919000 ( 5.919000)
79 # jruby-spymemcached get 5.615000 0.000000 5.615000 ( 5.615000)
80 # user system total real
81 # dalli set 10.132000 0.000000 10.132000 ( 10.132000)
82 # dalli get 10.600000 0.000000 10.600000 ( 10.600000)
83 #
84 ##############################################################################
85 #
86 # MBP 2.8G i7 jruby-memcached 0.1.0
87 #
88 # ruby-1.9.3-p194
89 # ruby benchmark.rb
9a10007 @flyerhzm add benchmark
flyerhzm authored
90 # user system total real
491f780 @flyerhzm add benchmark for 0.3.0
flyerhzm authored
91 # memcached set 1.110000 1.020000 2.130000 ( 4.592509)
92 # memcached get 0.970000 1.000000 1.970000 ( 4.172170)
9a10007 @flyerhzm add benchmark
flyerhzm authored
93 # user system total real
94 # dalli set 8.330000 1.560000 9.890000 ( 10.094499)
95 # dalli get 8.530000 1.680000 10.210000 ( 10.331083)
96 #
97 # jruby-1.6.7.2
98 # jruby --server -Ilib -S benchmark.rb
99 # user system total real
1e3865b @flyerhzm we do not use asynchronous api
flyerhzm authored
100 # jruby-memcached set 6.902000 0.000000 6.902000 ( 6.902000)
101 # jruby-memcached get 6.845000 0.000000 6.845000 ( 6.845000)
9a10007 @flyerhzm add benchmark
flyerhzm authored
102 # user system total real
1e3865b @flyerhzm we do not use asynchronous api
flyerhzm authored
103 # dalli set 13.251000 0.000000 13.251000 ( 13.251000)
104 # dalli get 13.536000 0.000000 13.536000 ( 13.536000)
Something went wrong with that request. Please try again.