Skip to content

Instantly share code, notes, and snippets.

@MMercieca
Created September 19, 2016 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MMercieca/24a72221d16c02aeec659614a0ac5d04 to your computer and use it in GitHub Desktop.
Save MMercieca/24a72221d16c02aeec659614a0ac5d04 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'benchmark'
command= "#{ARGV.shift} &> /dev/null"
run_times = ARGV.shift.to_i
usage = "benchmark.rb <command> <times_to_run>"
unless run_times > 0
fail usage
end
unless system(command)
fail "#{command} failed"
end
puts "Running #{command}"
puts "#{run_times} times"
Benchmark.bm do |x|
x.report do
run_times.times do
system(command)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment