1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace AlecRabbit\Tools\Traits; |
4
|
|
|
|
5
|
|
|
use AlecRabbit\Accessories\MemoryUsage\MemoryUsageReport; |
6
|
|
|
use AlecRabbit\Tools\Internal\BenchmarkFunction; |
7
|
|
|
use AlecRabbit\Tools\Profiler; |
8
|
|
|
use AlecRabbit\Tools\SimpleCounter; |
9
|
|
|
use AlecRabbit\Tools\Timer; |
10
|
|
|
|
11
|
|
|
trait BenchmarkFields |
12
|
|
|
{ |
13
|
|
|
/** @var BenchmarkFunction[] */ |
14
|
|
|
protected $functions = []; |
15
|
|
|
|
16
|
|
|
// /** @var Profiler */ |
17
|
|
|
// protected $profiler; |
18
|
|
|
// |
19
|
|
|
/** @var MemoryUsageReport */ |
20
|
|
|
protected $memoryUsageReport; |
21
|
|
|
|
22
|
|
|
/** @var int */ |
23
|
|
|
protected $doneIterations = 0; |
24
|
|
|
|
25
|
|
|
/** @var int */ |
26
|
|
|
protected $doneIterationsCombined = 0; |
27
|
|
|
|
28
|
|
|
/** @var Timer */ |
29
|
|
|
protected $timer; |
30
|
|
|
|
31
|
|
|
/** @var SimpleCounter */ |
32
|
|
|
protected $added; |
33
|
|
|
|
34
|
|
|
/** @var SimpleCounter */ |
35
|
|
|
protected $benchmarked; |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @return BenchmarkFunction[] |
40
|
|
|
*/ |
41
|
|
|
public function getFunctions(): array |
42
|
|
|
{ |
43
|
|
|
return $this->functions; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return int |
48
|
|
|
*/ |
49
|
|
|
public function getDoneIterations(): int |
50
|
|
|
{ |
51
|
|
|
return $this->doneIterations; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @return Timer |
56
|
|
|
*/ |
57
|
|
|
public function getTimer(): Timer |
58
|
|
|
{ |
59
|
|
|
return $this->timer; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @return int |
64
|
|
|
*/ |
65
|
|
|
public function getDoneIterationsCombined(): int |
66
|
|
|
{ |
67
|
|
|
return $this->doneIterationsCombined; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @return MemoryUsageReport |
72
|
|
|
*/ |
73
|
|
|
public function getMemoryUsageReport(): MemoryUsageReport |
74
|
|
|
{ |
75
|
|
|
return $this->memoryUsageReport; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return SimpleCounter |
80
|
|
|
*/ |
81
|
|
|
public function getAdded(): SimpleCounter |
82
|
|
|
{ |
83
|
|
|
return $this->added; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return SimpleCounter |
88
|
|
|
*/ |
89
|
|
|
public function getBenchmarked(): SimpleCounter |
90
|
|
|
{ |
91
|
|
|
return $this->benchmarked; |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|