Skip to content

Commit

Permalink
ktest: Add timings for commands
Browse files Browse the repository at this point in the history
I find that I usually like to see how long a make or other command takes,
and adding a start and end time and reporting how long each command runs
(in seconds) is helpful.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Steven Rostedt (Red Hat) committed Jan 27, 2015
1 parent 97bf6af commit b53486e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tools/testing/ktest/ktest.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1534,10 +1534,14 @@ sub fail {

sub run_command {
my ($command, $redirect) = @_;
my $start_time;
my $end_time;
my $dolog = 0;
my $dord = 0;
my $pid;

$start_time = time;

$command =~ s/\$SSH_USER/$ssh_user/g;
$command =~ s/\$MACHINE/$machine/g;

Expand Down Expand Up @@ -1570,6 +1574,15 @@ sub run_command {
close(LOG) if ($dolog);
close(RD) if ($dord);

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

if ($delta == 1) {
doprint "[1 second] ";
} else {
doprint "[$delta seconds] ";
}

if ($failed) {
doprint "FAILED!\n";
} else {
Expand Down

0 comments on commit b53486e

Please sign in to comment.