Skip to contentSkip to conversation

ktest.pl: Add total test run time to output

PATCH New Steven Rostedt 1 participant 1 message Oct 20 Ktest

lore
Share & tools
lore

Steven Rostedt

author maintainer
#0 lore raw

PATCH 1/1 ktest.pl: Add total test run time to output

From: Steven Rostedt <[email protected]>

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.

---
 tools/testing/ktest/ktest.pl | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
tools/testing/ktest/ktest.pl +15 -0
index f94ed2e98887..29d29c40807b 100755
@@ -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;
Signature · 1 line
2.53.0