Skip to content

Instantly share code, notes, and snippets.

@jacobo
Created June 28, 2019 18:58
Show Gist options
  • Save jacobo/46cf340e5c6ec86eb61535976a2cde5d to your computer and use it in GitHub Desktop.
Save jacobo/46cf340e5c6ec86eb61535976a2cde5d to your computer and use it in GitHub Desktop.
benchmark a series of method calls
class CaptureThings
attr_reader :things
def initialize(&block)
@things = []
instance_eval(&block)
end
def method_missing(thing)
@things << thing.to_s
end
end
def benchmark_each(&block)
CaptureThings.new(&block).things.each do |page_method|
require 'benchmark'
puts page_method
puts Benchmark.measure { self.send(page_method) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment