Skip to content
Browse files

Added test:times target

  • Loading branch information...
1 parent 4bb3a78 commit 96d072e83667cded2986dc30288c6f0d77ace340 @jimweirich committed Mar 13, 2011
Showing with 25 additions and 0 deletions.
  1. +25 −0 rakelib/test_times.rake
View
25 rakelib/test_times.rake
@@ -0,0 +1,25 @@
+module TestTimes
+ def self.run(test_results, limit=0)
+ limit = limit.nonzero? || 10
+ tests = []
+ test_results.split(/\n/).each do |line|
+ if line =~ /^(.+?#[^:]+): ([0-9.]+) s: \.$/
+ tests << [$1, $2.to_f, line]
+ end
+ end
+
+ puts "#{limit} Slowest tests"
+ puts tests.sort_by { |item|
+ item[1]
+ }.reverse[0...limit].map { |item|
+ "%6.3f: %-s\n" % [item[1], item[0]]
+ }
+ end
+end
+
+namespace :test do
+ desc "Find the slowest unit tests"
+ task :times, [:limit] do |t, args|
+ TestTimes.run `rake test:units TESTOPTS='--verbose'`, args.limit.to_i
+ end
+end

0 comments on commit 96d072e

Please sign in to comment.
Something went wrong with that request. Please try again.