Created
April 21, 2009 01:06
-
-
Save bcardarella/98869 to your computer and use it in GitHub Desktop.
Benchmark your Test::Unit tests
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
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