Skip to content

Instantly share code, notes, and snippets.

@chrisbloom7
Forked from harley/rake_benchmark.rb
Created June 8, 2016 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisbloom7/8597765ff0c24f206e6e90b0116fa2ba to your computer and use it in GitHub Desktop.
Save chrisbloom7/8597765ff0c24f206e6e90b0116fa2ba 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