mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Subject: [for-next][PATCH 3/9] ktest: Show times for build, install, boot and test
Date: Wed, 04 Feb 2015 14:50:50 -0500	[thread overview]
Message-ID: <20150204195123.363468148@goodmis.org> (raw)
In-Reply-To: <20150204195047.818126814@goodmis.org>

[-- Attachment #1: 0003-ktest-Show-times-for-build-install-boot-and-test.patch --]
[-- Type: text/plain, Size: 5273 bytes --]

From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

Seeing the times for how long a build, install, reboot and the
test takes is helpful for analyzing the test process. Seeing
how different changes affect the timings.

Show the build, install, boot and test times when at the end of
the test, or between each interval for tests that do those
mulitple times (like bisect and patchcheck).

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 tools/testing/ktest/ktest.pl | 109 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 105 insertions(+), 4 deletions(-)

diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index 1dae000f79f8..177319822401 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -198,6 +198,11 @@ my $patchcheck_start;
 my $patchcheck_cherry;
 my $patchcheck_end;
 
+my $build_time;
+my $install_time;
+my $reboot_time;
+my $test_time;
+
 # set when a test is something other that just building or install
 # which would require more options.
 my $buildonly = 1;
@@ -555,6 +560,66 @@ sub get_mandatory_config {
     }
 }
 
+sub show_time {
+    my ($time) = @_;
+
+    my $hours = 0;
+    my $minutes = 0;
+
+    if ($time > 3600) {
+	$hours = int($time / 3600);
+	$time -= $hours * 3600;
+    }
+    if ($time > 60) {
+	$minutes = int($time / 60);
+	$time -= $minutes * 60;
+    }
+
+    if ($hours > 0) {
+	doprint "$hours hour";
+	doprint "s" if ($hours > 1);
+	doprint " ";
+    }
+
+    if ($minutes > 0) {
+	doprint "$minutes minute";
+	doprint "s" if ($minutes > 1);
+	doprint " ";
+    }
+
+    doprint "$time second";
+    doprint "s" if ($time != 1);
+}
+
+sub print_times {
+    doprint "\n";
+    if ($build_time) {
+	doprint "Build time:   ";
+	show_time($build_time);
+	doprint "\n";
+    }
+    if ($install_time) {
+	doprint "Install time: ";
+	show_time($install_time);
+	doprint "\n";
+    }
+    if ($reboot_time) {
+	doprint "Reboot time:  ";
+	show_time($reboot_time);
+	doprint "\n";
+    }
+    if ($test_time) {
+	doprint "Test time:    ";
+	show_time($test_time);
+	doprint "\n";
+    }
+    # reset for iterations like bisect
+    $build_time = 0;
+    $install_time = 0;
+    $reboot_time = 0;
+    $test_time = 0;
+}
+
 sub get_mandatory_configs {
     get_mandatory_config("MACHINE");
     get_mandatory_config("BUILD_DIR");
@@ -1786,6 +1851,8 @@ sub monitor {
     my $skip_call_trace = 0;
     my $loops;
 
+    my $start_time = time;
+
     wait_for_monitor 5;
 
     my $line;
@@ -1910,6 +1977,9 @@ sub monitor {
 	}
     }
 
+    my $end_time = time;
+    $reboot_time = $end_time - $start_time;
+
     close(DMESG);
 
     if ($bug) {
@@ -1958,6 +2028,8 @@ sub install {
 
     return if ($no_install);
 
+    my $start_time = time;
+
     if (defined($pre_install)) {
 	my $cp_pre_install = eval_kernel_version $pre_install;
 	run_command "$cp_pre_install" or
@@ -1989,6 +2061,8 @@ sub install {
     if (!$install_mods) {
 	do_post_install;
 	doprint "No modules needed\n";
+	my $end_time = time;
+	$install_time = $end_time - $start_time;
 	return;
     }
 
@@ -2016,6 +2090,9 @@ sub install {
     run_ssh "rm -f /tmp/$modtar";
 
     do_post_install;
+
+    my $end_time = time;
+    $install_time = $end_time - $start_time;
 }
 
 sub get_version {
@@ -2228,6 +2305,8 @@ sub build {
 
     unlink $buildlog;
 
+    my $start_time = time;
+
     # Failed builds should not reboot the target
     my $save_no_reboot = $no_reboot;
     $no_reboot = 1;
@@ -2313,6 +2392,9 @@ sub build {
 
     $no_reboot = $save_no_reboot;
 
+    my $end_time = time;
+    $build_time = $end_time - $start_time;
+
     return 1;
 }
 
@@ -2403,6 +2485,8 @@ sub do_run_test {
     my $bug = 0;
     my $bug_ignored = 0;
 
+    my $start_time = time;
+
     wait_for_monitor 1;
 
     doprint "run test $run_test\n";
@@ -2469,6 +2553,9 @@ sub do_run_test {
     waitpid $child_pid, 0;
     $child_exit = $?;
 
+    my $end_time = time;
+    $test_time = $end_time - $start_time;
+
     if (!$bug && $in_bisect) {
 	if (defined($bisect_ret_good)) {
 	    if ($child_exit == $bisect_ret_good) {
@@ -2775,6 +2862,7 @@ sub bisect {
     do {
 	$result = run_bisect $type;
 	$test = run_git_bisect "git bisect $result";
+	print_times;
     } while ($test);
 
     run_command "git bisect log" or
@@ -3188,6 +3276,7 @@ sub config_bisect {
 
     do {
 	$ret = run_config_bisect \%good_configs, \%bad_configs;
+	print_times;
     } while (!$ret);
 
     return $ret if ($ret < 0);
@@ -3317,10 +3406,12 @@ sub patchcheck {
 	    do_run_test or $failed = 1;
 	}
 	end_monitor;
-	return 0 if ($failed);
-
+	if ($failed) {
+	    print_times;
+	    return 0;
+	}
 	patchcheck_reboot;
-
+	print_times;
     }
     $in_patchcheck = 0;
     success $i;
@@ -4020,6 +4111,11 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
 
     $iteration = $i;
 
+    $build_time = 0;
+    $install_time = 0;
+    $reboot_time = 0;
+    $test_time = 0;
+
     undef %force_config;
 
     my $makecmd = set_test_option("MAKE_CMD", $i);
@@ -4183,9 +4279,14 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) {
 	    do_run_test or $failed = 1;
 	}
 	end_monitor;
-	next if ($failed);
+	if ($failed) {
+	    print_times;
+	    next;
+	}
     }
 
+    print_times;
+
     success $i;
 }
 
-- 
2.1.4



  parent reply	other threads:[~2015-02-04 19:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-04 19:50 [for-next][PATCH 0/9] ktest: Updates for 3.20 Steven Rostedt
2015-02-04 19:50 ` [for-next][PATCH 1/9] ktest: Add timings for commands Steven Rostedt
2015-02-04 19:50 ` [for-next][PATCH 2/9] ktest: Restore tty settings after closing console Steven Rostedt
2015-02-04 19:50 ` Steven Rostedt [this message]
2015-02-04 19:50 ` [for-next][PATCH 4/9] ktest: Rename start_monitor_and_boot to start_monitor_and_install Steven Rostedt
2015-02-04 19:50 ` [for-next][PATCH 5/9] ktest: Give console process a dedicated tty Steven Rostedt
2015-02-04 19:50 ` [for-next][PATCH 6/9] ktest: Enable user input to the console Steven Rostedt
2015-02-04 19:50 ` [for-next][PATCH 7/9] ktest: Print build,install,boot,test times at success and failure Steven Rostedt
2015-02-04 19:50 ` [for-next][PATCH 8/9] ktest: Cleanup terminal on dodie() failure Steven Rostedt
2015-02-04 19:50 ` [for-next][PATCH 9/9] ktest: Place quotes around item variable Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150204195123.363468148@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®