Make Timings and TimingPoint implement Stringable.
This commit is contained in:
parent
6f9ab9136e
commit
16e9676430
3 changed files with 22 additions and 5 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
0.2504.31450
|
||||
0.2504.31518
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
<?php
|
||||
// TimingPoint.php
|
||||
// Created: 2022-02-16
|
||||
// Updated: 2025-02-27
|
||||
// Updated: 2025-04-03
|
||||
|
||||
namespace Index\Performance;
|
||||
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* Represents a timing point.
|
||||
*/
|
||||
class TimingPoint {
|
||||
class TimingPoint implements Stringable {
|
||||
/**
|
||||
* @param int $timePoint Starting tick count.
|
||||
* @param int $duration Duration tick count.
|
||||
|
@ -30,4 +32,14 @@ class TimingPoint {
|
|||
public int|float $durationTime {
|
||||
get => $this->duration / PerformanceCounter::frequency();
|
||||
}
|
||||
|
||||
public function __toString(): string {
|
||||
$string = $this->name;
|
||||
if(!empty($this->comment))
|
||||
$string .= sprintf(';desc="%s"', rawurlencode($this->comment));
|
||||
|
||||
$string .= sprintf(';dur=%.5f', $this->durationTime);
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
<?php
|
||||
// Timings.php
|
||||
// Created: 2022-02-16
|
||||
// Updated: 2025-02-27
|
||||
// Updated: 2025-04-03
|
||||
|
||||
namespace Index\Performance;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Stringable;
|
||||
|
||||
/**
|
||||
* Represents a Stopwatch with timing points.
|
||||
*/
|
||||
class Timings {
|
||||
class Timings implements Stringable {
|
||||
public private(set) Stopwatch $stopwatch;
|
||||
private int $lastLapTicks;
|
||||
|
||||
|
@ -74,4 +75,8 @@ class Timings {
|
|||
$comment
|
||||
);
|
||||
}
|
||||
|
||||
public function __toString(): string {
|
||||
return implode(', ', $this->laps);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue