chore: initial import for test contour
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service\Performance;
|
||||
|
||||
class PerformanceTrackerService
|
||||
{
|
||||
private ?float $startTime = null;
|
||||
private ?float $endTime = null;
|
||||
|
||||
public function start(): void
|
||||
{
|
||||
$this->startTime = microtime(true);
|
||||
$this->endTime = null;
|
||||
}
|
||||
|
||||
public function stop(): void
|
||||
{
|
||||
$this->endTime = microtime(true);
|
||||
}
|
||||
|
||||
public function getDurationMs(): int
|
||||
{
|
||||
if (!$this->startTime) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$endTime = $this->endTime ?? microtime(true);
|
||||
return (int)round(($endTime - $this->startTime) * 1000);
|
||||
}
|
||||
|
||||
public function reset(): void
|
||||
{
|
||||
$this->startTime = null;
|
||||
$this->endTime = null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user