From 7211d0baed1e77db85ab0c21062ddeeecac7caaf Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Mon, 23 Mar 2026 14:49:23 +0100 Subject: Switch ULTRATIME and some other runtime measurements to hrtime() --- it.class | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'it.class') 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; } -- cgit v1.2.3