1
- #! /usr/bin/ruby
1
+ #!/usr/bin/ruby
2
2
$:. unshift File . expand_path ( '../../lib' , __FILE__ )
3
3
4
+ require 'bundler/setup'
4
5
require 'i18n'
5
6
require 'benchmark'
6
7
require 'yaml'
7
8
8
- DATA_STORES = ARGV . delete ( "-ds" )
9
9
N = ( ARGV . shift || 1000 ) . to_i
10
10
YAML_HASH = YAML . load_file ( File . expand_path ( "example.yml" , File . dirname ( __FILE__ ) ) )
11
11
@@ -16,20 +16,16 @@ module Backends
16
16
include I18n ::Backend ::InterpolationCompiler
17
17
end . new
18
18
19
- if DATA_STORES
20
- require 'rubygems'
21
- require File . expand_path ( '../../test/test_setup/active_record' , __FILE__ )
22
- require File . expand_path ( '../../test/test_setup/rufus_tokyo' , __FILE__ )
23
-
24
- Test . setup_active_record
25
- ActiveRecord = I18n ::Backend ::ActiveRecord . new if defined? ( ::ActiveRecord )
26
-
27
- Test . setup_rufus_tokyo
28
- TokyoCabinet = I18n ::Backend ::KeyValue . new ( Rufus ::Tokyo ::Cabinet . new ( "*" ) , true ) if defined? ( ::Rufus ::Tokyo )
19
+ begin
20
+ require 'active_support'
21
+ KeyValue = I18n ::Backend ::KeyValue . new ( { } , true )
22
+ puts "Running KeyValue with ActiveSupport #{ ActiveSupport ::VERSION ::STRING } "
23
+ rescue LoadError
24
+ puts 'Skipping KeyValue since ActiveSupport could not be loaded.'
29
25
end
30
26
end
31
27
32
- ORDER = %w( Simple Interpolation ActiveRecord TokyoCabinet )
28
+ ORDER = %w( Simple Interpolation KeyValue )
33
29
ORDER . map! ( &:to_sym ) if RUBY_VERSION > '1.9'
34
30
35
31
module Benchmark
@@ -62,7 +58,7 @@ def self.measure_objects(n, &blk)
62
58
puts "=> #{ backend_name } \n \n "
63
59
64
60
Benchmark . rt "store" , 1 do
65
- I18n . backend . store_translations * ( YAML_HASH . to_a . first )
61
+ I18n . backend . store_translations ( * YAML_HASH . to_a . first )
66
62
end
67
63
68
64
I18n . backend . translate :en , :first
@@ -114,4 +110,4 @@ def self.measure_objects(n, &blk)
114
110
end
115
111
116
112
puts "Running memoized benchmarks with N = #{ N } \n \n "
117
- ( ORDER & Backends . constants ) . each ( &benchmarker )
113
+ ( ORDER & Backends . constants ) . each ( &benchmarker )
0 commit comments