Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (39 sloc) 877 Bytes
require "benchmark"
$:.push File.join(File.dirname(__FILE__), 'lib')
require 'redis'
ITERATIONS = 10000
@r = Redis.new
Benchmark.bmbm do |benchmark|
benchmark.report("set") do
@r.flushdb
ITERATIONS.times do |i|
@r.set("foo#{i}", "Hello world!")
@r.get("foo#{i}")
end
end
benchmark.report("set (pipelined)") do
@r.flushdb
@r.pipelined do
ITERATIONS.times do |i|
@r.set("foo#{i}", "Hello world!")
@r.get("foo#{i}")
end
end
end
benchmark.report("lpush+ltrim") do
@r.flushdb
ITERATIONS.times do |i|
@r.lpush "lpush#{i}", i
@r.ltrim "ltrim#{i}", 0, 30
end
end
benchmark.report("lpush+ltrim (pipelined)") do
@r.flushdb
@r.pipelined do
ITERATIONS.times do |i|
@r.lpush "lpush#{i}", i
@r.ltrim "ltrim#{i}", 0, 30
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.