Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix benchmark & readme

  • Loading branch information...
commit 4aece329638d669dc5db1365251b9d159aebb4c7 1 parent 4837c01
@nofxx authored
View
4 README.rdoc
@@ -3,7 +3,7 @@
Rack based Tokyo stored (FAST!) Rails session store.
Code:: http://github.com/nofxx/tokyo_store
-Demo:: http://github.com/nofxx/tokyo_webapps under rails/session
+Demo:: http://github.com/nofxx/tokyo_webapps under rails/tokyo_store
== Require
@@ -16,6 +16,8 @@ Rufus Tokyo:: http://github.com/jmettraux/rufus-tokyo
gem install nofxx-tokyo_store
+Rails (enviroment.rb)
+
config.gem 'nofxx-tokyo_store', :lib => 'tokyo_store'
ActionController::Base.session_store = Rack::Session::Tokyo
View
80 benchmark/tokyo_store.rb → benchmark/cache.rb
@@ -7,20 +7,21 @@
require 'active_support'
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
-require 'tokyo_store'
+require 'cache/tokyo_store'
#include TokyoCabinet
P = "x" * 100
M = P * 10
G = M * 10
-OBJ = { :small => P, :medium => M, :big => G}
+X = { :small => P, :medium => M, :big => G}
#TODO: Cabinet & memcached C bindings
@tokyo = ActiveSupport::Cache.lookup_store :tokyo_store, "localhost:1978"
@memca = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost:11211"
@memto = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost:1978"
-# # # Read & Write
+puts " Write"
+puts "--------------"
Benchmark.bmbm do |b|
b.report("TokyoStore# P") { 10_000.times { |i| @tokyo.write i.to_s, P }}
b.report("MemCacheD # P") { 10_000.times { |i| @memca.write i.to_s, P }}
@@ -31,15 +32,6 @@
b.report("TokyoStore# G") { 10_000.times { |i| @tokyo.write i.to_s, G }}
b.report("MemCacheD # G") { 10_000.times { |i| @memca.write i.to_s, G }}
b.report("MemCacheT # G") { 10_000.times { |i| @memto.write i.to_s, G }}
- b.report("TokyoStore# OB") { 10_000.times { |i| @tokyo.write i.to_s, OBJ }}
- b.report("MemCacheD # OB") { 10_000.times { |i| @memca.write i.to_s, OBJ }}
- b.report("MemCacheT # OB") { 10_000.times { |i| @memto.write i.to_s, OBJ }}
- b.report("TokyoStore# R") { 10_000.times { |i| @tokyo.read i.to_s }}
- b.report("MemCacheD # R") { 10_000.times { |i| @memca.read i.to_s }}
- b.report("MemCacheT # R") { 10_000.times { |i| @memto.read i.to_s }}
- b.report("TokyoStore# E") { 10_000.times { |i| @tokyo.exist? i.to_s }}
- b.report("MemCacheD # E") { 10_000.times { |i| @memca.exist? i.to_s }}
- b.report("MemCacheT # E") { 10_000.times { |i| @memto.exist? i.to_s }}
b.report("TokyoStore# D") { 10_000.times { |i| @tokyo.delete i.to_s }}
b.report("MemCacheD # D") { 10_000.times { |i| @memca.delete i.to_s }}
b.report("MemCacheT # D") { 10_000.times { |i| @memto.delete i.to_s }}
@@ -51,13 +43,27 @@
b.report("MemCacheT # -") { 10_000.times { |i| @memto.decrement i.to_s }}
end
+puts " Read"
+puts "--------------"
+#TODO: implement read with diff data. ALl should probably be 0 here
+Benchmark.bmbm do |b|
+ b.report("TokyoStore# Seq") { 10_000.times { |i| @tokyo.read i.to_s }}
+ b.report("MemCacheD # Seq") { 10_000.times { |i| @memca.read i.to_s }}
+ b.report("MemCacheT # Seq") { 10_000.times { |i| @memto.read i.to_s }}
+ b.report("TokyoStore# Rand") { 10_000.times { |i| @tokyo.read rand(i).to_s }}
+ b.report("MemCacheD # Rand") { 10_000.times { |i| @memca.read rand(i).to_s }}
+ b.report("MemCacheT # Rand") { 10_000.times { |i| @memto.read rand(i).to_s }}
+ b.report("TokyoStore# Exist") { 10_000.times { |i| @tokyo.exist? i.to_s }}
+ b.report("MemCacheD # Exist") { 10_000.times { |i| @memca.exist? i.to_s }}
+ b.report("MemCacheT # Exist") { 10_000.times { |i| @memto.exist? i.to_s }}
+end
+
puts
thr = []
-# # Read & Write
Benchmark.bmbm do |b|
- b.report("Tokyo # W") { 100.times { |j| thr << Thread.new { 100.times { |i| @tokyo.write "#{j}-#{i}", OBJ }}}; thr.each { |t| t.join }; thr = [] }
- b.report("MemCa # W") { 100.times { |j| thr << Thread.new { 100.times { |i| @memca.write "#{j}-#{i}", OBJ}}}; thr.each { |t| t.join }; thr = [] }
- b.report("MemTo # W") { 100.times { |j| thr << Thread.new { 100.times { |i| @memto.write "#{j}-#{i}", OBJ}}}; thr.each { |t| t.join }; thr = [] }
+ b.report("Tokyo # W") { 100.times { |j| thr << Thread.new { 100.times { |i| @tokyo.write "#{j}-#{i}", X }}}; thr.each { |t| t.join }; thr = [] }
+ b.report("MemCa # W") { 100.times { |j| thr << Thread.new { 100.times { |i| @memca.write "#{j}-#{i}", X}}}; thr.each { |t| t.join }; thr = [] }
+ b.report("MemTo # W") { 100.times { |j| thr << Thread.new { 100.times { |i| @memto.write "#{j}-#{i}", X}}}; thr.each { |t| t.join }; thr = [] }
b.report("Tokyo # R") { 100.times { |j| thr << Thread.new { 100.times { |i| @tokyo.read "#{j}-#{i}" }}}; thr.each { |t| t.join }; thr = [] }
b.report("MemCa # R") { 100.times { |j| thr << Thread.new { 100.times { |i| @memca.read "#{j}-#{i}"}}}; thr.each { |t| t.join }; thr = [] }
b.report("MemTo # R") { 100.times { |j| thr << Thread.new { 100.times { |i| @memto.read "#{j}-#{i}"}}}; thr.each { |t| t.join }; thr = [] }
@@ -69,6 +75,8 @@
Core 2 Duo 8500 - 3.16Ghz
------------------------------------------------------------
+ Write
+-------------
TokyoStore# P 0.140000 0.090000 0.230000 ( 0.367587)
MemCacheD # P 0.570000 0.160000 0.730000 ( 0.829167)
MemCacheT # P 0.560000 0.170000 0.730000 ( 0.897084)
@@ -78,18 +86,9 @@
TokyoStore# G 0.410000 0.090000 0.500000 ( 0.976746)
MemCacheD # G 1.000000 0.200000 1.200000 ( 1.429635)
MemCacheT # G 1.060000 0.170000 1.230000 ( 1.558731)
-TokyoStore# OB 0.480000 0.130000 0.610000 ( 1.299556)
-MemCacheD # OB 1.460000 0.280000 1.740000 ( 1.980678)
-MemCacheT # OB 1.230000 0.230000 1.460000 ( 1.856561)
-TokyoStore# R 0.620000 0.230000 0.850000 ( 1.204192)
-MemCacheD # R 0.550000 0.110000 0.660000 ( 0.748446)
-MemCacheT # R 1.490000 0.260000 1.750000 ( 2.142504)
-TokyoStore# P 0.150000 0.090000 0.240000 ( 0.393119)
-MemCacheD # P 0.640000 0.150000 0.790000 ( 0.896260)
-MemCacheT # P 0.660000 0.170000 0.830000 ( 0.966585)
-TokyoStore# E 0.120000 0.100000 0.220000 ( 0.359803)
-MemCacheD # E 0.720000 0.130000 0.850000 ( 0.969214)
-MemCacheT # E 0.820000 0.160000 0.980000 ( 1.195356)
+TokyoStore# X 0.480000 0.130000 0.610000 ( 1.299556)
+MemCacheD # X 1.460000 0.280000 1.740000 ( 1.980678)
+MemCacheT # X 1.230000 0.230000 1.460000 ( 1.856561)
TokyoStore# D 0.220000 0.170000 0.390000 ( 0.707877)
MemCacheD # D 0.560000 0.110000 0.670000 ( 0.775865)
MemCacheT # D 0.560000 0.140000 0.700000 ( 0.860964)
@@ -100,9 +99,22 @@
MemCacheD # - 0.600000 0.100000 0.700000 ( 0.778212)
MemCacheT # - 0.600000 0.140000 0.740000 ( 0.983345)
-Tokyo # W 0.500000 0.100000 0.600000 ( 1.189529)
-MemCa # W 2.390000 0.250000 2.640000 ( 2.942472)
-MemTo # W 2.550000 0.260000 2.810000 ( 3.121612)
-Tokyo # R 0.660000 0.230000 0.890000 ( 1.266911)
-MemCa # R 1.550000 0.190000 1.740000 ( 1.824773)
-MemTo # R 3.170000 0.280000 3.450000 ( 3.908895)
+ Read
+--------------
+TokyoStore# Seq 0.440000 0.150000 0.590000 ( 0.858501)
+MemCacheD # Seq 0.830000 0.220000 1.050000 ( 1.135630)
+MemCacheT # Seq 1.210000 0.190000 1.400000 ( 1.754004)
+TokyoStore# Rand 0.490000 0.200000 0.690000 ( 1.003466)
+MemCacheD # Rand 0.870000 0.170000 1.040000 ( 1.135382)
+MemCacheT # Rand 1.410000 0.230000 1.640000 ( 1.971372)
+TokyoStore# Exist 0.460000 0.140000 0.600000 ( 0.845920)
+MemCacheD # Exist 0.810000 0.220000 1.030000 ( 1.138310)
+MemCacheT # Exist 1.150000 0.250000 1.400000 ( 1.760770)
+
+
+Tokyo # W 0.510000 0.150000 0.660000 ( 1.023739)
+MemCa # W 2.530000 0.210000 2.740000 ( 3.072881)
+MemTo # W 2.600000 0.280000 2.880000 ( 3.344125)
+Tokyo # R 0.680000 0.210000 0.890000 ( 2.547828)
+MemCa # R 2.190000 0.240000 2.430000 ( 2.977408)
+MemTo # R 3.210000 0.330000 3.540000 ( 4.298882)
View
4 lib/cache/tokyo_store.rb
@@ -1,6 +1,6 @@
-# require 'rufus/tokyo/tyrant'
+require 'rufus/tokyo/tyrant'
# require 'tokyocabinet'
-module Rack
+module ActiveSupport
module Cache
# A cache store implementation which stores data in Tokyo Cabinet

0 comments on commit 4aece32

Please sign in to comment.
Something went wrong with that request. Please try again.