Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 31 lines (29 sloc) 0.556 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
if ARGV.size < 2 or ARGV.size > 3
  $stderr.puts "Usage: #{__FILE__} <n-iterations> <file.rb> [suite]"
  exit 1
end
N = ARGV[0].to_i
file = ARGV[1]
@suite = ARGV[2]
@perf_tests = []
def perf_test(name, &b)
  if @suite == nil or @suite == name
    @perf_tests << [name, b]
  end
end

load(file)

@perf_tests.each do |name, proc|
  times = []
  N.times do
    ts = Time.now
    begin
      proc.call
      res = Time.now - ts
      times << ("%1.6f" % res)
    rescue
      times = ['ERROR']
      break
    end
  end
  puts "#{name}:#{times.join(",")}"
end
Something went wrong with that request. Please try again.