Skip to content

Instantly share code, notes, and snippets.

@alfie-max
Forked from harley/rake_benchmark.rb
Created September 7, 2020 12:25
Show Gist options
  • Save alfie-max/f945de122241e4eb4a3a35135e576b1a to your computer and use it in GitHub Desktop.
Save alfie-max/f945de122241e4eb4a3a35135e576b1a to your computer and use it in GitHub Desktop.
Benchmarking a rake task
# Put this in Rakefile (doesn't matter where)
require 'benchmark'
class Rake::Task
def execute_with_benchmark(*args)
bm = Benchmark.measure { execute_without_benchmark(*args) }
puts " #{name} --> #{bm}"
end
alias_method :execute_without_benchmark, :execute
alias_method :execute, :execute_with_benchmark
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment