summaryrefslogtreecommitdiff
path: root/test/racc/bench.y
blob: c6ba136201552fc24002c24d29ac0efe5d227608 (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
29
30
31
32
33
34
35
36
class BenchmarkParser

rule

  target: a a a a a   a a a a a;
  a:      b b b b b   b b b b b;
  b:      c c c c c   c c c c c;
  c:      d d d d d   d d d d d;
  d:      e e e e e   e e e e e;

end

---- inner

def initialize
  @old = [ :e, 'e' ]
  @i = 0
end

def next_token
  return [false, '$'] if @i >= 10_0000
  @i += 1
  @old
end

def parse
  do_parse
end

---- footer

require 'benchmark'

Benchmark.bm do |x|
  x.report { BenchmarkParser.new.parse }
end