mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
36 lines
463 B
Text
36 lines
463 B
Text
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
|