Created
November 16, 2011 04:53
-
-
Save sssionggg/1369278 to your computer and use it in GitHub Desktop.
base62 convertor in ruby
This file contains 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
require 'rubygems' | |
require 'benchmark' | |
require 'alphadecimal' | |
time = Benchmark.measure do | |
1_000_000.times do |i| | |
encode = i.alphadecimal | |
decode = encode.alphadecimal | |
raise "Assertion error!" unless i == decode | |
end | |
end | |
puts time # 17.060000 0.050000 17.110000 ( 17.507562) |
This file contains 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
require 'rubygems' | |
require 'benchmark' | |
require 'base62' | |
time = Benchmark.measure do | |
1_000_000.times do |i| | |
encode = i.base62_encode | |
decode = encode.base62_decode | |
raise "Assertion error!" unless i == decode | |
end | |
end | |
puts time # 9.600000 0.020000 9.620000 ( 9.802189) |
This file contains 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
require 'rubygems' | |
require 'benchmark' | |
require 'radix62' | |
time = Benchmark.measure do | |
1_000_000.times do |i| | |
encode = i.encode62 | |
decode = encode.decode62 | |
raise "Assertion error!" unless i == decode | |
end | |
end | |
puts time # 19.070000 0.040000 19.110000 ( 19.483596) |
This file contains 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
require 'rubygems' | |
require 'benchmark' | |
require 'yab62' | |
time = Benchmark.measure do | |
1_000_000.times do |i| | |
encode = i.encode62 | |
decode = encode.decode62 | |
raise "Assertion error!" unless i == decode | |
end | |
end | |
puts time # 0.550000 0.000000 0.550000 ( 0.605562) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment