Skip to content

Commit

Permalink
Debugger::timer: switch from microtime to hrtime
Browse files Browse the repository at this point in the history
hrtime is faster on virtual machines, due microtime use system call that need to change context from user to kernel (PHP7.3+)
  • Loading branch information
bckp authored and dg committed Jan 10, 2022
1 parent 3d143a9 commit f652fae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Tracy/Debugger/Debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,10 @@ public static function dump(mixed $var, bool $return = false): mixed
public static function timer(?string $name = null): float
{
static $time = [];
$now = microtime(true);
$now = hrtime(true);
$delta = isset($time[$name]) ? $now - $time[$name] : 0;
$time[$name] = $now;
return $delta;
return $delta / 1e+9;
}


Expand Down

0 comments on commit f652fae

Please sign in to comment.