Sha256: 5edf67211fa57bc4437c97513a009737142f035712414b56863ce2a92d4acf91

Contents?: true

Size: 801 Bytes

Versions: 31

Compression:

Stored size: 801 Bytes

Contents

require "test_helper"
require 'stringex'
require 'i18n'
require 'benchmark'

class LocalizationPerformanceTest < Test::Unit::TestCase
  def setup
    I18n.locale = :en
    Stringex::Localization.reset!
  end

  def test_i18n_performance
    Stringex::Localization.backend = :internal
    internal_time = Benchmark.realtime { 100.times{ "alskdjfal".to_url } }

    Stringex::Localization.backend = :i18n
    i18n_time = Benchmark.realtime { 100.times{ "alskdjfal".to_url } }

    percentage_difference = ((i18n_time - internal_time) / internal_time) * 100
    allowed_difference = 25

    assert percentage_difference <= allowed_difference, "The I18n backend is #{percentage_difference.to_i} percent slower than the internal backend. The allowed difference is #{allowed_difference} percent."
  end
end

Version data entries

31 entries across 30 versions & 2 rubygems

Version Path
stringex-2.2.0 test/performance/localization_performance_test.rb
stringex-2.1.2 test/performance/localization_performance_test.rb
stringex-2.1.1 test/performance/localization_performance_test.rb
stringex-2.1.0 test/performance/localization_performance_test.rb
stringex-2.0.11 test/performance/localization_performance_test.rb
stringex-2.0.10 test/performance/localization_performance_test.rb
stringex-2.0.9 test/performance/localization_performance_test.rb
stringex-2.0.8 test/performance/localization_performance_test.rb
stringex-2.0.7 test/performance/localization_performance_test.rb
stringex-2.0.6 test/performance/localization_performance_test.rb
stringex-2.0.5 test/performance/localization_performance_test.rb