Skip to content

Instantly share code, notes, and snippets.

@matsubo
Created April 23, 2015 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matsubo/d440e25f013ff59356f9 to your computer and use it in GitHub Desktop.
Save matsubo/d440e25f013ff59356f9 to your computer and use it in GitHub Desktop.
require 'benchmark'
require 'redis'
require 'securerandom'
hosts = {
:docker => { :host => '172.17.8.102', :port => 6379 },
:virtualbox => { :host => '33.33.11.10', :port => 6379 },
}
hosts.each do |key, host|
puts key
redis = Redis.new(:host => host[:host], :port => host[:port], :db => 15)
n = 5000
Benchmark.bm do |x|
x.report('set') { n.times do ; redis.set SecureRandom.hex(10), SecureRandom.hex(10) ; end }
x.report('get') { n.times do ; redis.get SecureRandom.hex(10) ; end }
end
end
@matsubo
Copy link
Author

matsubo commented Apr 23, 2015

Result

% ruby redis.rb
docker
       user     system      total        real
set  0.710000   0.230000   0.940000 ( 44.176670)
get  0.590000   0.200000   0.790000 ( 35.968567)
virtualbox
       user     system      total        real
set  0.370000   0.140000   0.510000 (  6.892621)
get  0.360000   0.150000   0.510000 (  6.434613)
ruby redis.rb  2.17s user 0.86s system 3% cpu 1:34.24 total

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment