Advertisement
Guest User

Untitled

a guest
Apr 28th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. def benchmark
  2. # Your benchmarking code goes here.
  3. start_time = Time.now
  4. yield
  5. end_time = Time.now
  6. end_time - start_time
  7. end
  8.  
  9. # Be careful, pasting this into IRB will take a long time to print.
  10. # It's a loooong string. :)
  11. long_string = "apple"*100000000
  12.  
  13. running_time = benchmark { long_string.reverse }
  14.  
  15. puts "string.reverse took #{running_time} seconds to run"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement