Created
May 22, 2009 12:38
-
-
Save actsasflinn/116096 to your computer and use it in GitHub Desktop.
ruby-tokyotyrant takes @kamal's url shortener test
This file contains hidden or 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
# 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) | |
id = T.add_int("global:next.url.id", 1) # this line accounts for 1 second of the 1.2 seconds | |
T.putnr("url:#{id}", url) | |
"http://example.com/#{id.to_i.to_s(32)}" | |
end | |
10000.times { | |
shorten("http://github.com/actsasflinn/ruby-tokyotyrant/tree/master") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment