Created
June 28, 2019 18:58
-
-
Save jacobo/46cf340e5c6ec86eb61535976a2cde5d to your computer and use it in GitHub Desktop.
benchmark a series of method calls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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