Created
August 27, 2008 12:52
-
-
Save mattetti/7471 to your computer and use it in GitHub Desktop.
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
| simple backend using #translate | Ruby hash | #1/#2 | | |
-------------------------------------------------------------------------------------------------- | |
lookup with locale given x100000 | 3.560 | 0.061 | 58.54x | | |
| no key | key with scope | hash key being nil | #1/#3 | | |
---------------------------------------------------------------------------------------------------- | |
lookup with no key given x100000 | 1.422 | 3.577 | 0.045 | 31.77x | |
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
require "rubygems" | |
require "rbench" | |
$:.unshift "./../lib" | |
require File.dirname(__FILE__) + '/../lib/i18n' | |
require 'time' | |
TIMES = 100_000 | |
RBench.run(TIMES) do | |
column :times | |
column :one, :title => "simple backend using #translate" | |
column :two, :title => "Ruby hash" | |
column :diff, :title => "#1/#2", :compare => [:one,:two] | |
report "lookup with locale given" do | |
@backend = I18n::Backend::Simple.new | |
@backend.store_translations 'en-US', :foo => {:bar => 'bar', :baz => 'baz'} | |
@memory_hash = {:'en-US' => {:foo => {:bar => 'bar', :baz => 'baz'}} } | |
one { @backend.translate('en-US', :bar, :scope => [:foo]) } | |
two { @memory_hash[:'en-US'][:foo][:bar] } | |
end | |
end | |
RBench.run(TIMES) do | |
column :times | |
column :one, :title => "no key" | |
column :two, :title => "key with scope" | |
column :three, :title => "hash key being nil" | |
column :diff, :title => "#1/#3", :compare => [:one,:three] | |
report "lookup with no key given" do | |
@backend = I18n::Backend::Simple.new | |
@backend.store_translations 'en-US', :foo => {:bar => 'bar', :baz => 'baz'} | |
@memory_hash = {:'en-US' => {:foo => {:bar => 'bar', :baz => 'baz'}} } | |
one { @backend.translate('en-US', nil, :default => 'default') } | |
two { @backend.translate('en-US', :bar, :scope => [:foo]) } | |
three { @memory_hash[:test] } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment