Skip to content

Commit

Permalink
Remove rufus and old AR support from benchmark script
Browse files Browse the repository at this point in the history
Remove warning: `*' interpreted as argument prefix'`
  • Loading branch information
carlosantoniodasilva committed Jul 16, 2014
1 parent 10c07ff commit 5e1ce48
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions benchmark/run.rb
@@ -1,11 +1,11 @@
#! /usr/bin/ruby
#!/usr/bin/ruby
$:.unshift File.expand_path('../../lib', __FILE__)

require 'bundler/setup'
require 'i18n'
require 'benchmark'
require 'yaml'

DATA_STORES = ARGV.delete("-ds")
N = (ARGV.shift || 1000).to_i
YAML_HASH = YAML.load_file(File.expand_path("example.yml", File.dirname(__FILE__)))

Expand All @@ -16,20 +16,16 @@ module Backends
include I18n::Backend::InterpolationCompiler
end.new

if DATA_STORES
require 'rubygems'
require File.expand_path('../../test/test_setup/active_record', __FILE__)
require File.expand_path('../../test/test_setup/rufus_tokyo', __FILE__)

Test.setup_active_record
ActiveRecord = I18n::Backend::ActiveRecord.new if defined?(::ActiveRecord)

Test.setup_rufus_tokyo
TokyoCabinet = I18n::Backend::KeyValue.new(Rufus::Tokyo::Cabinet.new("*"), true) if defined?(::Rufus::Tokyo)
begin
require 'active_support'
KeyValue = I18n::Backend::KeyValue.new({}, true)
puts "Running KeyValue with ActiveSupport #{ActiveSupport::VERSION::STRING}"
rescue LoadError
puts 'Skipping KeyValue since ActiveSupport could not be loaded.'
end
end

ORDER = %w(Simple Interpolation ActiveRecord TokyoCabinet)
ORDER = %w(Simple Interpolation KeyValue)
ORDER.map!(&:to_sym) if RUBY_VERSION > '1.9'

module Benchmark
Expand Down Expand Up @@ -62,7 +58,7 @@ def self.measure_objects(n, &blk)
puts "=> #{backend_name}\n\n"

Benchmark.rt "store", 1 do
I18n.backend.store_translations *(YAML_HASH.to_a.first)
I18n.backend.store_translations(*YAML_HASH.to_a.first)
end

I18n.backend.translate :en, :first
Expand Down Expand Up @@ -114,4 +110,4 @@ def self.measure_objects(n, &blk)
end

puts "Running memoized benchmarks with N = #{N}\n\n"
(ORDER & Backends.constants).each(&benchmarker)
(ORDER & Backends.constants).each(&benchmarker)

0 comments on commit 5e1ce48

Please sign in to comment.