#!ruby -Imswin32
# AOT compiler test (benchmark)

require 'yarvutil'
require 'benchmark'

$line = __LINE__ + 3
###########################################################
$prog  =<<'__EOP__'

def compiled n
  if n < 2
    1
  else
    compiled(n-1) + compiled(n-2)
  end
end

compiled 32

__EOP__

$progc =<<'__EOP__'

compiled 32

__EOP__
###########################################################

puts YARVUtil.parse($prog, $0, $line).disasm
exit if ARGV[0] == 'po'

$lpback = $".dup

puts
puts "aotc\t" + Benchmark.measure{
  YARVUtil.eval($progc, $0, $line)
}.to_s
__END__
puts "ruby\t" + Benchmark.measure{
  YARVUtil.eval_in_wrap($prog, $0, $line)
}.to_s
puts "yarv\t" + Benchmark.measure{
  YARVUtil.eval($prog, $0, $line)
}.to_s
