Skip to content

Instantly share code, notes, and snippets.

@gangelo
Created January 25, 2018 01:19
Show Gist options
  • Save gangelo/5b9d7b8f4cb038bc57e4675dc78f3413 to your computer and use it in GitHub Desktop.
Save gangelo/5b9d7b8f4cb038bc57e4675dc78f3413 to your computer and use it in GitHub Desktop.
Benchmark Helper
require 'benchmark'
=begin
# Example use
do_benchmark("Each loop test") do
(1..100).each do |n|
puts (n * n).to_s
end
end
=end
module Benchmark
module Helpers
def do_benchmark(title = nil)
puts title unless title.nil?
Benchmark.bm do |benchmark|
benchmark.report do
yield
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment