Skip to content

Instantly share code, notes, and snippets.

@s4m-sepiol
Forked from davidvandusen/benchmark_with_block.rb
Created December 5, 2016 19:33
Show Gist options
  • Select an option

  • Save s4m-sepiol/d6124611029c5e2e2ab9bb4b72812136 to your computer and use it in GitHub Desktop.

Select an option

Save s4m-sepiol/d6124611029c5e2e2ab9bb4b72812136 to your computer and use it in GitHub Desktop.
def benchmark
# Your benchmarking code goes here.
end
# Be careful, pasting this into IRB will take a long time to print.
# It's a loooong string. :)
long_string = "apple"*100000000
running_time = benchmark { long_string.reverse }
puts "string.reverse took #{running_time} seconds to run"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment