$ analyze_tests.pl Number of test programs: 47 Total runtime approximately 19 minutes 56 seconds Ten slowest tests: +---------+--------------------------------------------+ | Time | Test | +---------+--------------------------------------------+ | 12m 22s | t/acceptance.t | | 4m 26s | t/aggregate.t | | 0m 31s | t/standards/use.t | | 0m 14s | t/system/both/import/log/pager.t | | 0m 12s | t/system/both/import/log/search.t | | 0m 10s | t/unit/piptest/pprove/testdb.t | | 0m 9s | t/system/both/import/log/log.t | | 0m 8s | t/unit/db/migrations.t | | 0m 7s | t/system/api/v1/programme/programmes.t | | 0m 6s | t/system/both/reports/imports/validation.t | +---------+--------------------------------------------+ #### #!/usr/bin/env perl use strict; use warnings; use App::Prove::State; use List::Util 'sum'; use Lingua::EN::Numbers 'num2en'; use Text::Table; sub minutes_and_seconds { my $seconds = shift; return ( int($seconds / 60), int($seconds % 60) ); } my $state = App::Prove::State->new({ store => '.prove' }); my $generation = $state->{_}{generation}; my $tests = $state->{_}{tests}; my $total = sum(map { $_->{elapsed} } values %$tests); my ( $minutes, $seconds ) = minutes_and_seconds($total); my $num_tests = shift || 10; my $total_tests = keys %$tests; if ($num_tests > $total_tests) { $num_tests = $total_tests; } my $num_word = num2en($num_tests); my %time_for; while (my ($test, $data) = each %$tests) { $time_for{$test} = $data->{elapsed}; } my @sorted_by_time_desc = sort { $time_for{$b} <=> $time_for{$a} } keys %time_for; print "Number of test programs: $total_tests\n"; print "Total runtime approximately $minutes minutes $seconds seconds\n\n"; print "\u$num_word slowest tests:\n"; my $table = Text::Table->new(\'| ', 'Time', \' | ', 'Test', \' |' ); $table->rule(qw(- +)); $table->body_rule(qw(- +)); my @rows; for ( 0 .. $num_tests - 1 ) { my $test = $sorted_by_time_desc[$_]; my $time = $time_for{$test}; my ( $minutes, $seconds ) = minutes_and_seconds($time); push @rows => [ "${minutes}m ${seconds}s", $test, ]; } $table->load(@rows); my @body = map { $table->body($_) } 0 .. $num_tests - 1; print $table->rule(qw(- + )), $table->title, $table->rule(qw(- + )), @body, $table->rule(qw(- + ));