forked from openwrt/openwrt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace the GNU time program invocation with a simple Perl script reporting the timing values. Since we require Perl anyway for the build system, we can as well use that instead of requiring a random GNU utility rarely installed by default. Fixes: ff6e62b ("build: log time taken by each packages/steps") Signed-off-by: Jo-Philipp Wich <[email protected]>
- Loading branch information
Showing
3 changed files
with
43 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env perl | ||
|
||
use strict; | ||
use warnings; | ||
use Time::HiRes qw(gettimeofday); | ||
|
||
if (@ARGV < 2) { | ||
die "Usage: $0 <prefix> <command...>\n"; | ||
} | ||
|
||
my ($prefix, @cmd) = @ARGV; | ||
my ($sec, $msec) = gettimeofday(); | ||
my $pid = fork(); | ||
|
||
if (!defined($pid)) { | ||
die "$0: Failure to fork(): $!\n"; | ||
} | ||
elsif ($pid == 0) { | ||
exec(@cmd); | ||
die "$0: Failure to exec(): $!\n"; | ||
} | ||
else { | ||
$SIG{'INT'} = 'IGNORE'; | ||
$SIG{'QUIT'} = 'IGNORE'; | ||
|
||
if (waitpid($pid, 0) == -1) { | ||
die "$0: Failure to waitpid(): $!\n"; | ||
} | ||
|
||
my $exitcode = $? >> 8; | ||
my ($sec2, $msec2) = gettimeofday(); | ||
my (undef, undef, $cuser, $csystem) = times(); | ||
|
||
printf STDERR "%s#%.2f#%.2f#%.2f\n", | ||
$prefix, $cuser, $csystem, | ||
($sec2 - $sec) + ($msec2 - $msec) / 1000000; | ||
|
||
$SIG{'INT'} = 'DEFAULT'; | ||
$SIG{'QUIT'} = 'DEFAULT'; | ||
|
||
exit $exitcode; | ||
} |