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