Skip to content

Instantly share code, notes, and snippets.

@actsasflinn
actsasflinn / gist:74116
Created March 5, 2009 00:46
ruby-tokyotyrant c client TABLE benchmark
=begin
Tokyo::TyrantTable (Ruby FFI)
user system total real
inserting data 0.840000 0.190000 1.030000 ( 3.214565)
reading data 1.310000 0.210000 1.520000 ( 3.024142)
TokyoTyrant::RDB (Ruby)
user system total real
inserting data 1.170000 0.240000 1.410000 ( 2.859321)
@actsasflinn
actsasflinn / gist:75212
Created March 7, 2009 03:56
ruby-tokyotyrant c client benchmark
=begin
Tokyo::Tyrant (Ruby FFI)
user system total real
inserting data 0.140000 0.180000 0.320000 ( 1.208150)
reading data 0.240000 0.170000 0.410000 ( 1.467640)
TokyoTyrant::RDB (Ruby)
user system total real
inserting data 0.300000 0.170000 0.470000 ( 1.481900)
@actsasflinn
actsasflinn / gist:82206
Created March 20, 2009 04:27
Benchmark of ruby-tokyotyrant + thin + sinatra + crazy object experiment (no caching)
$ ab -c 100 -n 1000 http://0.0.0.0:9292/1
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 0.0.0.0 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
@actsasflinn
actsasflinn / gist:83194
Created March 22, 2009 15:19
Bulk Operation (10k write/read) with ruby-tokyotyrant
=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)
@actsasflinn
actsasflinn / gist:87215
Created March 28, 2009 22:01
Bulk Table Operation (10k write/read) with ruby-tokyotyrant
=begin
Tokyo Tyrant Bulk Table Operations Benchmark
TokyoTyrant (C)
user system total real
bulk writing data 0.180000 0.000000 0.180000 ( 0.292081)
bulk reading data 0.120000 0.020000 0.140000 ( 0.216074)
#!/usr/bin/env ruby
# use this to install the same gems you have installed under one ruby in another
# run "gem list > ~/Desktop/gems.txt"
# run "ruby install_gems.rb /Users/r38y/Desktop/gems.txt"
gems = IO.readlines(ARGV.first)
gems.map! do |g|
stuff = g.split(' ')
gem_name = stuff.delete_at(0)
stuff.map{|v| v.gsub(/[\(\)\,]/, '')}.map{|v| "sudo gem install #{gem_name} -v=#{v}"}
@actsasflinn
actsasflinn / gist:116096
Created May 22, 2009 12:38
ruby-tokyotyrant takes @kamal's url shortener test
# URL shortener used to benchmark redis-rb and RubyRedis applied to ruby-tokyotyrant
# Script takes 1.2 seconds
require 'rubygems'
require 'benchmark'
require 'tokyo_tyrant'
puts Benchmark.realtime{
T=TokyoTyrant::DB.new('127.0.0.1', 45000)
def shorten(url)
require 'tokyo_tyrant'
t = TokyoTyrant::Table.new('127.0.0.1', 1978)
100.times do |i|
t[i] = { 'name' => "Pat #{i}", 'sex' => i % 2 > 0 ? 'male' : 'female' }
end
q = t.query
q.condition('sex', :streq, 'male')
q.limit(5)
@actsasflinn
actsasflinn / gist:160348
Created August 3, 2009 03:35
experiment with Tokyo Tyrant as an ActiveRecord cache layer
require 'tokyo_tyrant'
$tyrant = TokyoTyrant::Table.new
module Cacheable
module TyrantTable
def self.included(base) #:nodoc:
super
base.class_eval %q{
cattr_accessor :cache_records
@@cache_records = false
@actsasflinn
actsasflinn / TyrantRecord.rb
Created August 10, 2009 03:39
TyrantRecord, an experimental interface for modeling using Tokyo Tyrant
# Tyrannical
require 'tokyo_tyrant'
class TrueClass
def to_tokyo_tyrant;"1";end
end
class FalseClass
def to_tokyo_tyrant;"0";end