ktest.pl: Add total test run time to output

It can be interesting to know what the total time of all the tests took.
Instead of just seeing the time for each individual test, at the end of
the test (even on failure) show the total time the test took to complete.
This can also help identify if something has changed in the setup that
should be investigated if the times suddenly increase drastically.

Link: https://patch.msgid.link/20261020103338.4be97a72@gandalf.local.home
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
Steven Rostedt 2026-10-20 10:33:38 -04:00
parent bd1413cdee
commit bde7aa6d4b

View File

@ -227,6 +227,7 @@ my $build_time;
my $install_time;
my $reboot_time;
my $test_time;
my $start_run_time;
my $warning_found = 0;
@ -1609,6 +1610,14 @@ sub run_post_ktest {
$post_ktest_done = 1;
}
sub show_run_time {
return if (!$start_run_time);
my $end_run_time = time;
doprint "\n Total run time: ";
show_time($end_run_time - $start_run_time);
doprint "\n";
}
sub dodie {
# avoid recursion
return if ($in_die);
@ -1631,6 +1640,8 @@ sub dodie {
`$power_off`;
}
show_run_time();
if (defined($opt{"LOG_FILE"})) {
print " See $opt{LOG_FILE} for more info.\n";
}
@ -4534,6 +4545,8 @@ print_test_preamble 0;
$SIG{INT} = qw(cancel_test);
$start_run_time = time;
# First we need to do is the builds
for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
@ -4766,6 +4779,8 @@ if ($email_when_finished) {
"$successes of $opt{NUM_TESTS} tests started at $script_start_time were successful!");
}
show_run_time();
if (defined($opt{"LOG_FILE"})) {
print "\n See $opt{LOG_FILE} for the record of results.\n\n";
close LOG;