1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace SavinMikhail\CommentsDensity\AnalyzeComments\Metrics; |
||
6 | |||
7 | use SavinMikhail\CommentsDensity\AnalyzeComments\Analyzer\DTO\Output\PerformanceMetricsDTO; |
||
0 ignored issues
–
show
|
|||
8 | |||
9 | use function memory_get_peak_usage; |
||
10 | use function microtime; |
||
11 | use function round; |
||
12 | |||
13 | final class ResourceUtilization |
||
14 | { |
||
15 | private float $startTime; |
||
16 | |||
17 | private float $endTime; |
||
18 | |||
19 | private float $peakMemoryUsage; |
||
20 | |||
21 | 3 | public function start(): void |
|
22 | { |
||
23 | 3 | $this->startTime = microtime(true); |
|
24 | } |
||
25 | |||
26 | 2 | public function stop(): void |
|
27 | { |
||
28 | 2 | $this->endTime = microtime(true); |
|
29 | 2 | $this->peakMemoryUsage = memory_get_peak_usage(true); |
|
30 | } |
||
31 | |||
32 | 1 | public function getPerformanceMetrics(): PerformanceMetricsDTO |
|
33 | { |
||
34 | 1 | return new PerformanceMetricsDTO( |
|
35 | 1 | $this->getExecutionTime(), |
|
36 | 1 | $this->getPeakMemoryUsage(), |
|
37 | 1 | ); |
|
38 | } |
||
39 | |||
40 | 1 | private function getExecutionTime(): float |
|
41 | { |
||
42 | 1 | return round(($this->endTime - $this->startTime) * 1000, 2); |
|
43 | } |
||
44 | |||
45 | 1 | private function getPeakMemoryUsage(): float |
|
46 | { |
||
47 | 1 | return round($this->peakMemoryUsage / 1024 / 1024, 2); // Convert to MB |
|
48 | } |
||
49 | } |
||
50 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths