Skip to content

Instantly share code, notes, and snippets.

@ShopifyEng
Created May 8, 2020 13:35
Show Gist options
  • Save ShopifyEng/136c56273a70d5587d88d2930bb35c15 to your computer and use it in GitHub Desktop.
Save ShopifyEng/136c56273a70d5587d88d2930bb35c15 to your computer and use it in GitHub Desktop.
How to Fix Slow Code in Ruby - scir_simple_benchmark.rb
# frozen_string_literal: true
require "benchmark"
def some_method
sleep(1) # pause execution for 1 second
end
seconds = Benchmark.realtime { some_method }
puts "The method took #{seconds.truncate(2)} seconds."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment