Sha256: e71314d857ca22738cf418e079b8869084fda59a46922e78c40b5455dec49ba4

Contents?: true

Size: 963 Bytes

Versions: 31

Compression:

Stored size: 963 Bytes

Contents

require 'rubygems'
require 'benchmark'

RUNS = 50_0000
DEFAULTS = {:memory=>0}

def locale_folder(domain)
  path = case domain
  when 'test' then File.join(File.expand_path(File.dirname(__FILE__)),'..','spec','locale')
  when 'large' then File.join(File.expand_path(File.dirname(__FILE__)),'locale')
  end

  mo = File.join(path,'de','LC_MESSAGES',"#{domain}.mo")
  raise unless File.exist?(mo)
  path
end

def results_test(&block)
  print "#{(result(&block)).to_s.strip.split(' ').first}s / #{memory}K <-> "
end

def results_large
  print "#{(result {_('login') == 'anmelden'}).to_s.strip.split(' ').first}s / #{memory}K"
  puts ""
end

def result
  result =Benchmark.measure do
    RUNS.times do
      raise "not translated" unless yield
    end
  end
  result
end

def memory
  pid = Process.pid
  map = `pmap -d #{pid}`
  map.split("\n").last.strip.squeeze(' ').split(' ')[3].to_i - DEFAULTS[:memory]
end

DEFAULTS[:memory] = memory + 4 #4 => 0 for base calls

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
grosser-fast_gettext-0.4.12 benchmark/base.rb
grosser-fast_gettext-0.4.13 benchmark/base.rb
grosser-fast_gettext-0.4.14 benchmark/base.rb
grosser-fast_gettext-0.4.15 benchmark/base.rb
grosser-fast_gettext-0.4.16 benchmark/base.rb
fast_gettext-0.6.10 benchmark/base.rb
fast_gettext-0.6.9 benchmark/base.rb
fast_gettext-0.6.8 benchmark/base.rb
fast_gettext-0.6.7 benchmark/base.rb
fast_gettext-0.6.6 benchmark/base.rb
fast_gettext-0.6.5 benchmark/base.rb
fast_gettext-0.6.4 benchmark/base.rb
fast_gettext-0.6.3 benchmark/base.rb
fast_gettext-0.6.2 benchmark/base.rb
fast_gettext-0.6.1 benchmark/base.rb
fast_gettext-0.6.0 benchmark/base.rb
fast_gettext-0.5.13 benchmark/base.rb
fast_gettext-0.5.12 benchmark/base.rb
fast_gettext-0.5.11 benchmark/base.rb
fast_gettext-0.5.10 benchmark/base.rb