public
Last active

Bulk Operation (10k write/read) with ruby-tokyotyrant

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
=begin
Tokyo Tyrant Bulk Operations Benchmark
 
 
TokyoTyrant::RDB (Ruby) mget
user system total real
inserting data 7.770000 1.870000 9.640000 ( 12.598373)
reading data 1.540000 0.250000 1.790000 ( 2.290628)
 
 
TokyoTyrant (c) mput/mget
user system total real
inserting data 0.020000 0.000000 0.020000 ( 0.037996)
reading data 0.060000 0.010000 0.070000 ( 0.120651)
 
 
Memcached (C) set/get_multi
user system total real
inserting data* 0.160000 0.140000 0.300000 ( 0.884097)
reading data 0.090000 0.000000 0.090000 ( 0.140217)
* bulk operation not supported
=end
 
require 'benchmark'
require 'rubygems'
require 'faker'
 
puts "Tokyo Tyrant Bulk Operations Benchmark"
 
data = {}
data_e = {}
data_a = []
 
10_000.times do |i|
data[i.to_s] = Faker::Name.name
data_e[i.to_s] = nil
data_a << i.to_s
data_a << data[i.to_s]
end
 
require 'tokyotyrant'
 
rdb = TokyoTyrant::RDB::new
rdb.open("127.0.0.1", 45000)
rdb.clear
nothing = nil
 
2.times { puts }
puts 'TokyoTyrant::RDB (Ruby) mget'
 
Benchmark.benchmark(' ' * 20 + Benchmark::Tms::CAPTION, 20) do |b|
b.report('inserting data') do
rdb.misc('putlist', data_a)
end
 
b.report('reading data') do
rdb.mget(data_e)
end
end
 
require 'tokyo_tyrant'
t = TokyoTyrant::DB.new('127.0.0.1', 45000)
t.clear
nothing = nil
 
2.times { puts }
puts 'TokyoTyrant (c) mput/mget'
 
Benchmark.benchmark(' ' * 20 + Benchmark::Tms::CAPTION, 20) do |b|
b.report('inserting data ') do
t.mput(data)
end
 
b.report('reading data') do
nothing = t.mget(0..9999)
end
end
 
require 'memcached'
m = Memcached.new('127.0.0.1:11211')
m.flush
nothing = nil
 
2.times { puts }
puts 'Memcached (C) set/get_multi'
 
Benchmark.benchmark(' ' * 20 + Benchmark::Tms::CAPTION, 20) do |b|
b.report('inserting data*') do
data.each_pair { |k, v| m.set(k, v) }
end
 
b.report('reading data') do
nothing = m.get(data.keys)
end
end
 
puts "* bulk operation not supported"

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.