Total Complexity | 8 |
Total Lines | 80 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
5 | class StepTimeLogger |
||
6 | { |
||
7 | /** |
||
8 | * @var float |
||
9 | */ |
||
10 | private $lastStepStartTime; |
||
11 | |||
12 | /** |
||
13 | * @var array |
||
14 | */ |
||
15 | private $calledSteps = []; |
||
16 | |||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | private $executionTimes = []; |
||
21 | |||
22 | /** |
||
23 | * @param string $stepName |
||
24 | */ |
||
25 | public function logStepStarted($stepName) |
||
26 | { |
||
27 | $this->calledSteps[] = $stepName; |
||
28 | $this->lastStepStartTime = microtime(true); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * @param string $stepName |
||
33 | */ |
||
34 | public function logStepFinished($stepName) |
||
35 | { |
||
36 | $this->executionTimes[$stepName][] = microtime(true) - $this->lastStepStartTime; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @return void |
||
41 | */ |
||
42 | public function clearLogs() |
||
43 | { |
||
44 | $this->calledSteps = []; |
||
45 | $this->executionTimes = []; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @return array |
||
50 | */ |
||
51 | public function getCalledCounts() |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * @return array |
||
58 | */ |
||
59 | public function getAvegrageExecutionTimes() |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @return \Generator |
||
74 | */ |
||
75 | public function executionInformationGenerator() |
||
85 | ]; |
||
86 | } |
||
87 | } |
||
89 |