Skip to content

Commit

Permalink
ktest: Show times for build, install, boot and test
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Steven Rostedt (Red Hat) committed Jan 29, 2015
1 parent 9884278 commit 38fa3dc
Showing 1 changed file with 105 additions and 4 deletions.
109 changes: 105 additions & 4 deletions tools/testing/ktest/ktest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@
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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -1786,6 +1851,8 @@ sub monitor {
my $skip_call_trace = 0;
my $loops;

my $start_time = time;

wait_for_monitor 5;

my $line;
Expand Down Expand Up @@ -1910,6 +1977,9 @@ sub monitor {
}
}

my $end_time = time;
$reboot_time = $end_time - $start_time;

close(DMESG);

if ($bug) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -2313,6 +2392,9 @@ sub build {

$no_reboot = $save_no_reboot;

my $end_time = time;
$build_time = $end_time - $start_time;

return 1;
}

Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -4020,6 +4111,11 @@ sub set_test_option {

$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);
Expand Down Expand Up @@ -4183,9 +4279,14 @@ sub set_test_option {
do_run_test or $failed = 1;
}
end_monitor;
next if ($failed);
if ($failed) {
print_times;
next;
}
}

print_times;

success $i;
}

Expand Down

0 comments on commit 38fa3dc

Please sign in to comment.