Sha256: 0eb8e93a12950a3d6e8667ff957599a68d77af537fc3aa04dbe4d1adf0b5f678

Contents?: true

Size: 828 Bytes

Versions: 1

Compression:

Stored size: 828 Bytes

Contents

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

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)

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

  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

1 entries across 1 versions & 1 rubygems

Version Path
opal-wedge-0.9.0.dev benchmark/run.rb