Module: ShouldaAddons::MiniTest::Benchmark

Included in:
MiniTest::Unit
Defined in:
lib/shoulda_benchmark.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/shoulda_benchmark.rb', line 6

def self.included(base)
  base.class_eval do
    alias :run_before_benchmark :run
    
    def run args = []
      result = run_before_benchmark
      puts Shoulda.runtimes.collect{|name, total| [name, total]}.
        sort{|runtime1, runtime2| runtime2[1] <=> runtime1[1]}[0...10].
        collect{|name, total| "#{"%0.2f" % total} s: #{name.to_s.gsub(/test: /, "")}"}.<<("").join("\n")
      result
    end
  end
end