Sha256: a5dbb98df939096ddf40820b73a3f17fdb3298ec426f44bb3af12e25d22477df

Contents?: true

Size: 793 Bytes

Versions: 1

Compression:

Stored size: 793 Bytes

Contents

#$LOAD_PATH.unshift "../lib"

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

size = memory

Benchmark.bm(18){|x|
  x.report("Locale.default="){ 50000.times{|i|
     Locale.default = "ja-JP"
  } }
  x.report("Locale.default=(parse)"){ 50000.times{|i|
     Locale.default = Locale::Tag::Posix.parse("ja-JP.eucJP")
  } }
  x.report("Locale.default=(new)"){ 50000.times{|i|
     Locale.default = Locale::Tag::Posix.new("ja", "JP", "eucJP")
  } }
  Locale.default = nil
  x.report("Locale.candidates"){ 50000.times{|i|
     Locale.candidates
  } }
  Locale.default = nil
  x.report("Locale.current"){ 50000.times{|i|
     Locale.current
  } }
}

p "memory: #{memory - size}"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
locale-2.0.3 benchmark/benchmark.rb