Created
March 17, 2009 17:28
-
-
Save thedarkone/80667 to your computer and use it in GitHub Desktop.
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
$:.unshift "lib" | |
require 'i18n' | |
require "benchmark" | |
def with_fast?; defined?(I18n::Backend::Fast); end | |
str = 'abc {{a}}, {{b}}' | |
f = I18n::Backend::Fast.new if with_fast? | |
s = I18n::Backend::Simple.new | |
[f, s].compact.each {|b| b.store_translations 'en', :foo => {:bar => {:bax => {:buz => 'buz'}, :tr => str}, :baz => 'baz'}} | |
TESTS = 200_000 | |
Benchmark.bmbm do |results| | |
results.report("s.t(:'foo.bar.bax.buz')") do | |
TESTS.times { s.translate(:en, :'foo.bar.bax.buz') } | |
end | |
results.report("f.t(:'foo.bar.bax.buz')") do | |
TESTS.times { f.translate(:en, :'foo.bar.bax.buz') } | |
end if with_fast? | |
results.report("s.t(:'foo.bar.tr', :a => 'A', :b => 'B')") do | |
TESTS.times { s.translate(:en, :'foo.bar.tr', :a => 'A', :b => 'B') } | |
end | |
results.report("f.t(:'foo.bar.tr', :a => 'A', :b => 'B')") do | |
TESTS.times { f.translate(:en, :'foo.bar.tr', :a => 'A', :b => 'B') } | |
end if with_fast? | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment