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
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/stringex-2.8.6/test/performance/localization_performance_test.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/stringex-2.8.6/test/performance/localization_performance_test.rb
stringex-2.8.6 test/performance/localization_performance_test.rb
stringex-2.8.5 test/performance/localization_performance_test.rb
stringex-2.8.4 test/performance/localization_performance_test.rb
stringex-2.8.3 test/performance/localization_performance_test.rb
stringex-2.8.2 test/performance/localization_performance_test.rb
stringex-2.8.1 test/performance/localization_performance_test.rb
stringex-2.7.1 test/performance/localization_performance_test.rb
stringex-2.7.0 test/performance/localization_performance_test.rb
stringex-2.6.1 test/performance/localization_performance_test.rb
stringex-2.6.0 test/performance/localization_performance_test.rb
stringex-2.5.2 test/performance/localization_performance_test.rb
stringex-2.5.1 test/performance/localization_performance_test.rb
stringex-2.5.0 test/performance/localization_performance_test.rb
stringex-2.4.2 test/performance/localization_performance_test.rb
stringex-2.4.1 test/performance/localization_performance_test.rb
stringex-2.3.0 test/performance/localization_performance_test.rb
stringex-2.2.2 test/performance/localization_performance_test.rb
stringex-2.2.1 test/performance/localization_performance_test.rb