Total Complexity | 7 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | final class Profile implements ProfileInterface |
||
11 | { |
||
12 | private float $startTime = 0.0; |
||
13 | |||
14 | private float $stopTime = 0.0; |
||
15 | |||
16 | private int $peakMemoryUsage = 0; |
||
17 | |||
18 | private Time $time; |
||
19 | |||
20 | public function __construct(private string $transactionName, Time $time = null) |
||
21 | { |
||
22 | $this->time = $time ?? new Timer(); |
||
23 | } |
||
24 | |||
25 | public function startTransaction(): void |
||
26 | { |
||
27 | $this->startTime = $this->time->getMicroTime(); |
||
28 | } |
||
29 | |||
30 | public function endTransaction(): void |
||
31 | { |
||
32 | $this->stopTime = $this->time->getMicroTime(); |
||
33 | } |
||
34 | |||
35 | public function getTransactionName(): string |
||
36 | { |
||
37 | return $this->transactionName; |
||
38 | } |
||
39 | |||
40 | public function getElapsedSeconds(): float |
||
41 | { |
||
42 | return $this->stopTime - $this->startTime; |
||
43 | } |
||
44 | |||
45 | public function samplePeakMemoryUsage(): void |
||
46 | { |
||
47 | $this->peakMemoryUsage = memory_get_peak_usage(); |
||
48 | } |
||
49 | |||
50 | public function getPeakMemoryUsage(): int |
||
53 | } |
||
54 | } |
||
55 |