Allow specified the starting time of a stopwatch.

This commit is contained in:
flash 2025-04-03 14:50:38 +00:00
parent d06c105865
commit 6f9ab9136e
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E
2 changed files with 8 additions and 4 deletions
VERSION
src/Performance

View file

@ -1 +1 @@
0.2504.31447
0.2504.31450

View file

@ -1,7 +1,7 @@
<?php
// Stopwatch.php
// Created: 2021-04-26
// Updated: 2025-02-27
// Updated: 2025-04-03
namespace Index\Performance;
@ -9,11 +9,15 @@ namespace Index\Performance;
* Provides a means to measure elapsed time at a high resolution.
*/
class Stopwatch {
private int $start = -1;
private int $elapsed = 0;
private int $frequency;
public function __construct() {
/**
* @param int $start Starting value, must be the output of hrtime(true) if specified.
*/
public function __construct(
private int $start = -1
) {
$this->frequency = PerformanceCounter::frequency();
}