Created
November 15, 2015 15:24
-
-
Save shilovk/d2b961d55d0e33958193 to your computer and use it in GitHub Desktop.
This file contains 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
# coding: utf-8 | |
#https://github.com/logrusorgru/any/blob/master/redis_piplened_vs_ex/test.rb | |
require 'redis' | |
require 'benchmark' | |
# db: 0, driver: по-умолчанию, соединение: локальная петля, но(!) | |
# нам нужа производительность - чтобы не ждать результатов теста долго, поэтому | |
# кстати вот это: `driver: :hiredis, path: "/tmp/redis.sock"` | |
# увеличивает производительность чуть меньше чем в два раза | |
require 'hiredis' | |
$r = Redis.new driver: :hiredis, path: "/tmp/redis.sock" | |
count = 65000 | |
Benchmark.bm do |x| | |
x.report{ count.times{ |i| $r.set(i,nil,ex:10*60) } } | |
x.report{ count.times{ |i| $r.pipelined{ $r.set(i,nil); $r.expire(i,10*60) } } } | |
end | |
# обнуление базы данных | |
$r.flushdb | |
# | |
# user system total real | |
# 7.540000 2.870000 10.410000 ( 11.532065) | |
# 13.110000 4.450000 17.560000 ( 19.195621) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment