Created
October 7, 2011 06:30
-
-
Save satococoa/1269608 to your computer and use it in GitHub Desktop.
redis, memcachedのベンチマーク
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .bundle/ | |
| bundle/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| source :rubygems | |
| gem 'bundler' | |
| gem 'hiredis', '~> 0.3.1' | |
| gem 'redis', '~> 2.2.0', :require => ['redis/connection/hiredis', 'redis'] | |
| gem 'memcached' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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