summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
authorChristian Schneider2026-03-23 14:49:23 +0100
committerChristian Schneider2026-03-23 14:49:23 +0100
commit7211d0baed1e77db85ab0c21062ddeeecac7caaf (patch)
tree72d4568d4eb19270e17c7b8d8db2897a0ca92cd0 /it.class
parent53cea921e33a9bfc7f98e873c5f791f74edfaa78 (diff)
downloaditools-7211d0baed1e77db85ab0c21062ddeeecac7caaf.tar.gz
itools-7211d0baed1e77db85ab0c21062ddeeecac7caaf.tar.bz2
itools-7211d0baed1e77db85ab0c21062ddeeecac7caaf.zip
Switch ULTRATIME and some other runtime measurements to hrtime()
Diffstat (limited to 'it.class')
-rw-r--r--it.class10
1 files changed, 5 insertions, 5 deletions
diff --git a/it.class b/it.class
index 11641d7..0c2ec18 100644
--- a/it.class
+++ b/it.class
@@ -115,7 +115,7 @@ static function log_line($name, $line)
static function timerlog($label = '')
{
if ($GLOBALS['debug_timerlog'])
- $GLOBALS['ULTRATIMERLOG'] .= sprintf(" %s:%d", $label, (gettimeofday(true) - $GLOBALS['ULTRATIME'])*1000);
+ $GLOBALS['ULTRATIMERLOG'] .= sprintf(" %s:%d", $label, (hrtime(true) - $GLOBALS['ULTRATIME']) / 1_000_000);
}
@@ -688,12 +688,12 @@ static function exec($cmd, ...$args)
{
$args = array_reduce($args, fn($carry, $v) => array_merge($carry, (array)$v), []); # varargs to single array
$cmd = it::shell_command($cmd, $args); # NOPHPLINT
- $before = gettimeofday(true);
+ $before = hrtime(true);
if ((!($args['_callback'] instanceof Closure) || $args['_callback']($cmd)) && !EDC('noexec'))
$result = (string)shell_exec("set +o posix\n" . $cmd);
- @it::log('exec', round((gettimeofday(true) - $before)*1000) . "\t$cmd");
+ @it::log('exec', round((hrtime(true) - $before) / 1_000_000) . "\t$cmd");
return $result;
}
@@ -708,13 +708,13 @@ static function system($cmd, ...$args)
{
$args = array_reduce($args, fn($carry, $v) => array_merge($carry, (array)$v), []); # varargs to single array
$cmd = it::shell_command($cmd, $args); # NOPHPLINT
- $before = gettimeofday(true);
+ $before = hrtime(true);
$result = 0;
if ((!($args['_callback'] instanceof Closure) || $args['_callback']($cmd)) && !EDC('noexec'))
system("set +o posix\n" . $cmd, $result);
- @it::log('exec', round((gettimeofday(true) - $before)*1000) . "\t$cmd");
+ @it::log('exec', round((hrtime(true) - $before) / 1_000_000) . "\t$cmd");
return $result;
}