Created
January 25, 2018 01:19
-
-
Save gangelo/5b9d7b8f4cb038bc57e4675dc78f3413 to your computer and use it in GitHub Desktop.
Benchmark Helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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