Skip to content

Instantly share code, notes, and snippets.

@harley
Created July 14, 2012 22:36
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save harley/3113715 to your computer and use it in GitHub Desktop.
Save harley/3113715 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