[PATCH] ktest.pl: Add total test run time to output
From: Steven Rostedt
Date: Tue Oct 20 2026 - 11:14:50 EST
From: Steven Rostedt <rostedt@xxxxxxxxxxx>
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.
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
tools/testing/ktest/ktest.pl | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index f94ed2e98887..29d29c40807b 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -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;
--
2.53.0