Sha256: bf3efc5d8e7cf309c58216fadf70b80278a25a0fcc65b53f54783d113553ce0a

Contents?: true

Size: 996 Bytes

Versions: 24

Compression:

Stored size: 996 Bytes

Contents

if RUBY_ENGINE == 'opal'
  require 'opal/compiler'
  require 'nodejs'
end

BEST_OF_N = Integer(ENV['BEST_OF_N']) rescue 1

require 'benchmark'

files = ARGV

if files.empty?
  files = File.read('benchmark/benchmarks').lines.map(&:strip).reject do |line|
    line.empty? || line.start_with?('#')
  end
end

maxlen = files.max_by{|file| file.length}.length + 1

total_time = 0

files.each do |file|
  print file, " " * (maxlen - file.length)

  times = []

  if RUBY_ENGINE == 'opal'
    code = Opal.compile(File.read(file))
    BEST_OF_N.times do
      times << Benchmark.measure { `eval(code)` }
    end
  else
    code = File.read(file)
    BEST_OF_N.times do
      times << Benchmark.measure { eval(code) }
    end
  end

  time = times.min_by{|t| t.real}

  total_time += time.real

  print time.real, "\n"
end

bottom_line = "Executed #{ files.length } benchmark#{ 's' if files.length != 1} in #{ total_time } sec"
$stderr.print "=" * bottom_line.length, "\n"
$stderr.print bottom_line, "\n"

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
opal-0.10.6 benchmark/run.rb
opal-0.10.6.beta benchmark/run.rb
opal-0.11.0 benchmark/run.rb
opal-0.10.5 benchmark/run.rb
opal-0.10.4 benchmark/run.rb
opal-0.11.0.rc1 benchmark/run.rb
opal-0.10.3 benchmark/run.rb
opal-0.10.2 benchmark/run.rb
opal-0.10.1 benchmark/run.rb
opal-0.10.0 benchmark/run.rb
opal-0.10.0.rc2 benchmark/run.rb
opal-0.9.4 benchmark/run.rb
opal-0.9.3 benchmark/run.rb
opal-0.10.0.rc1 benchmark/run.rb
opal-0.10.0.beta5 benchmark/run.rb
opal-0.10.0.beta4 benchmark/run.rb
opal-0.10.0.beta3 benchmark/run.rb
opal-0.10.0.beta2 benchmark/run.rb
opal-0.10.0.beta1 benchmark/run.rb
opal-0.9.2 benchmark/run.rb