Skip to content

Instantly share code, notes, and snippets.

@bcardarella
Created April 21, 2009 01:06
Show Gist options
  • Save bcardarella/98869 to your computer and use it in GitHub Desktop.
Save bcardarella/98869 to your computer and use it in GitHub Desktop.
Benchmark your Test::Unit tests
require 'test/unit'
require 'benchmark'
class Test::Unit::TestCase
alias_method :real_run, :run unless instance_methods.include?("real_run")
@@total = {}
def run(result)
if block_given?
test = ::Benchmark.measure { real_run(result) { yield } }
else
test = ::Benchmark.measure { real_run(result) }
end
unless @@total.key?(self.class.to_s)
@@total[self.class.to_s] = []
end
@@total[self.class.to_s] << { :test => @method_name, :total => test.total }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment