Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Report slowest tests

  • Loading branch information...
commit f9df0ff18f10bc64d63ddf97be7a540d6bd86e49 1 parent c9ff743
Petter Wigle authored
Showing with 22 additions and 6 deletions.
  1. +5 −0 lib/parallel_tests/cli.rb
  2. +17 −6 lib/parallel_tests/test/runner.rb
View
5 lib/parallel_tests/cli.rb
@@ -49,6 +49,11 @@ def self.report_results(runner, test_results)
results = runner.find_results(test_results.map { |result| result[:stdout] }*"")
puts ""
puts runner.summarize_results(results)
+ puts ""
+ puts "Slowest tests:"
+ runner.slowest_tests.each do |test, time|
+ printf "%-40s: %.1f seconds\n", test, time
+ end
end
def self.report_number_of_tests(runner, groups)
View
23 lib/parallel_tests/test/runner.rb
@@ -106,18 +106,29 @@ def self.with_runtime_info(tests)
# use recorded test runtime if we got enough data
if lines.size * 1.5 > tests.size
puts "Using recorded test runtime"
- times = Hash.new(1)
- lines.each do |line|
- test, time = line.split(":")
- next unless test and time
- times[File.expand_path(test)] = time.to_f
- end
+ times = test_times(lines)
tests.sort.map{|test| [test, times[test]] }
else # use file sizes
tests.sort.map{|test| [test, File.stat(test).size] }
end
end
+ def self.test_times(lines)
+ times = Hash.new(1)
+ lines.each do |line|
+ test, time = line.split(":")
+ next unless test and time
+ times[File.expand_path(test)] = time.to_f
+ end
+ times
+ end
+
+ def self.slowest_tests
+ lines = File.read(runtime_log).split("\n") rescue []
+ times = test_times(lines)
+ times.sort {|a,b| b[1] <=> a[1] }
+ end
+
def self.find_tests(tests, options={})
(tests||[]).map do |file_or_folder|
if File.directory?(file_or_folder)
Please sign in to comment.
Something went wrong with that request. Please try again.