aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/gems/gettext-2.1.0/benchmark/test.rb
blob: 5765876078fc6ad8aba3cc1cdb3ff53052d0f277 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'benchmark'

def test(s)
  ret = ""
  if s =~ /^\#<|^$/ or s == "GetText"
  #if s.size == 0 or s[0..1] = "#<" or s == "GetText"
    ret = Object
  end
  ret
end

num = 100000

Benchmark.bm(25){|x|
  x.report("test matched"){ num.times{|i|
    test("#<foo>")
  } }
  x.report("test matched nodata"){ num.times{|i|
    test("")
  } }
  x.report("test matched GetText"){ num.times{|i|
    test("GetText")
  } }
  x.report("test not matched"){ num.times{|i|
    test("FooBar")
  } }

}