Skip to content

Instantly share code, notes, and snippets.

@jkirkpatrick24
Created July 27, 2016 23:03
Show Gist options
  • Save jkirkpatrick24/60029876df1987f6ac78e284fa85bfbb to your computer and use it in GitHub Desktop.
Save jkirkpatrick24/60029876df1987f6ac78e284fa85bfbb to your computer and use it in GitHub Desktop.

Revisions

  1. jkirkpatrick24 created this gist Jul 27, 2016.
    15 changes: 15 additions & 0 deletions Blocks with ruby
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    def benchmark
    start_time = Time.now
    yield
    end_time = Time.now
    final_time = end_time - start_time
    puts "string.reverse took #{final_time} seconds to run"
    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 }

    benchmark { puts "ashfsldkjflsdkjbfdjkbdkjfvkjsndf"}