summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2018-08-05 00:06:27 +0200
committerJo-Philipp Wich <jo@mein.io>2018-12-18 11:01:54 +0100
commitb4454ca4fae13f85e06d01df8a2a94ddd78d3368 (patch)
tree77330c1615e3c3daaaa8033579139e59e5d00b54 /scripts
parent43c96e8dd87ecc66448305484b824606bef8099b (diff)
downloadopenwrt-b4454ca4fae13f85e06d01df8a2a94ddd78d3368.tar.gz
openwrt-b4454ca4fae13f85e06d01df8a2a94ddd78d3368.tar.bz2
openwrt-b4454ca4fae13f85e06d01df8a2a94ddd78d3368.zip
build: remove GNU time dependency
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: ff6e62b288 ("build: log time taken by each packages/steps") Signed-off-by: Jo-Philipp Wich <jo@mein.io> (backported from d3ddf6631e491a831617a5ae8b3d7924e47a275a)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/time.pl42
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/time.pl b/scripts/time.pl
new file mode 100755
index 0000000000..cdc5824c83
--- /dev/null
+++ b/scripts/time.pl
@@ -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;
+}