Redis和Memcached在Ruby上的性能评测(2)——读取性能
上一篇我们测试了memcached和redis在ruby上的写入性能,这次我们来测试一下它们的单纯读取性能。
测试环境不变,代码只需要进行一点点修改
memcached测试代码:
require 'rubygems'require 'memcached'@cache = Memcached.new('localhost:11211')100000.times do |i| @cache.get "Test/#{rand(10000)}"end
require 'rubygems'require 'hiredis'@cache = Hiredis::Connection.new@cache.connect("127.0.0.1", 6379)100000.times do |i| @cache.write ['GET', "Test/#{rand(10000)}"] @cache.readend
realusersysmemcached1x GET pipeline10000 times0.783s0.274s0.285sredis1x GET pipeline10000 times1.114s0.417s0.375smemcached10x GET pipeline10000 times1.634s2.969s1.745sredis10x GET pipeline10000 times3.360s5.204s2.077smemcached20x GET pipeline10000 times3.163s6.081s3.587sredis20x GET pipeline10000 times6.588s10.634s4.338smemcached1x GET pipeline100000 times6.723s1.786s2.658sredis1x GET pipeline100000 times9.157s1.644s2.109smemcached10x GET pipeline100000 times12.237s17.363s14.919sredis10x GET pipeline100000 times24.886s16.058s14.649smemcached20x GET pipeline100000 times24.184s35.505s29.955sredis20x GET pipeline100000 times47.903s32.386s29.155smemcached1x GET pipeline1000000 times1m19.704s15.792s23.092sredis1x GET pipeline1000000 times1m30.097s15.186s24.438smemcached10x GET pipeline1000000 times1m57.467s2m44.216s2m23.563sredis10x GET pipeline1000000 times3m58.644s2m5.219s2m16.882smemcached20x GET pipeline1000000 times3m51.706s5m32.873s4m48.830sredis20x GET pipeline1000000 times7m28.133s4m5.430s4m28.178s