Skip to content

Instantly share code, notes, and snippets.

@satococoa
Created October 7, 2011 06:30
Show Gist options
  • Save satococoa/1269608 to your computer and use it in GitHub Desktop.
Save satococoa/1269608 to your computer and use it in GitHub Desktop.
redis, memcachedのベンチマーク
.bundle/
bundle/
# Usage:
# $ bundle install --path bundle
# $ bundle exec ruby benchmark.rb
#
require 'benchmark'
require 'bundler'
Bundler.require(:default)
TIMES = 10000
m = Memcached.new
r = Redis.new
text = 'foo'
Benchmark.bm do |b|
b.report('memcached:set') {
1.upto TIMES do |i|
m.set("foo_#{i}", "bar_#{i}")
end
}
b.report('memcached:get') {
1.upto TIMES do |i|
m.get("foo_#{i}")
end
}
b.report ('redis:set') {
1.upto TIMES do |i|
r.set("foo_#{i}", "bar_#{i}")
end
}
b.report ('redis:get') {
1.upto TIMES do |i|
r.get("foo_#{i}")
end
}
end
source :rubygems
gem 'bundler'
gem 'hiredis', '~> 0.3.1'
gem 'redis', '~> 2.2.0', :require => ['redis/connection/hiredis', 'redis']
gem 'memcached'
GEM
remote: http://rubygems.org/
specs:
hiredis (0.3.2)
memcached (1.3.3)
redis (2.2.2)
PLATFORMS
ruby
DEPENDENCIES
bundler
hiredis (~> 0.3.1)
memcached
redis (~> 2.2.0)
user system total real
memcached:set 0.310000 0.350000 0.660000 ( 1.996217)
memcached:get 0.240000 0.250000 0.490000 ( 1.091144)
redis:set 0.470000 0.310000 0.780000 ( 1.667288)
redis:get 0.460000 0.310000 0.770000 ( 1.649195)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment