1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace AlecRabbit\Tools\Traits; |
4
|
|
|
|
5
|
|
|
use AlecRabbit\Traits\GettableName; |
6
|
|
|
|
7
|
|
|
trait TimerFields |
8
|
|
|
{ |
9
|
|
|
use GettableName; |
10
|
|
|
|
11
|
|
|
/** @var float */ |
12
|
|
|
protected $previous = 0.0; |
13
|
|
|
|
14
|
|
|
/** @var float */ |
15
|
|
|
protected $creation = 0.0; |
16
|
|
|
|
17
|
|
|
/** @var float */ |
18
|
|
|
protected $elapsed = 0.0; |
19
|
|
|
|
20
|
|
|
/** @var bool */ |
21
|
|
|
protected $stopped = false; |
22
|
|
|
|
23
|
|
|
/** @var bool */ |
24
|
|
|
protected $started = false; |
25
|
|
|
|
26
|
|
|
/** @var float */ |
27
|
|
|
protected $currentValue = 0.0; |
28
|
|
|
|
29
|
|
|
/** @var float */ |
30
|
|
|
protected $avgValue = 0.0; |
31
|
|
|
|
32
|
|
|
/** @var float */ |
33
|
|
|
protected $minValue = 100000000.0; |
34
|
|
|
|
35
|
|
|
/** @var int */ |
36
|
|
|
protected $minValueIteration = 0; |
37
|
|
|
|
38
|
|
|
/** @var float */ |
39
|
|
|
protected $maxValue = 0.0; |
40
|
|
|
|
41
|
|
|
/** @var int */ |
42
|
|
|
protected $maxValueIteration = 0; |
43
|
|
|
|
44
|
|
|
/** @var int */ |
45
|
|
|
protected $count = 0; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @return bool |
49
|
|
|
*/ |
50
|
|
|
public function isStopped(): bool |
51
|
|
|
{ |
52
|
|
|
return $this->stopped; |
53
|
10 |
|
} |
54
|
|
|
|
55
|
10 |
|
/** |
56
|
|
|
* @return bool |
57
|
|
|
*/ |
58
|
|
|
public function isStarted(): bool |
59
|
|
|
{ |
60
|
|
|
return $this->started; |
61
|
5 |
|
} |
62
|
|
|
|
63
|
5 |
|
/** |
64
|
|
|
* @return bool |
65
|
|
|
*/ |
66
|
|
|
public function isNotStarted(): bool |
67
|
|
|
{ |
68
|
|
|
return !$this->started; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return float |
73
|
|
|
*/ |
74
|
|
|
public function getLastValue(): float |
75
|
|
|
{ |
76
|
|
|
return $this->currentValue; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return float |
81
|
|
|
*/ |
82
|
|
|
public function getAverageValue(): float |
83
|
|
|
{ |
84
|
|
|
return $this->avgValue; |
85
|
11 |
|
} |
86
|
|
|
|
87
|
11 |
|
/** |
88
|
|
|
* @return float |
89
|
|
|
*/ |
90
|
|
|
public function getMinValue(): float |
91
|
|
|
{ |
92
|
|
|
return $this->minValue; |
93
|
11 |
|
} |
94
|
|
|
|
95
|
11 |
|
/** |
96
|
|
|
* @return float |
97
|
|
|
*/ |
98
|
|
|
public function getMaxValue(): float |
99
|
|
|
{ |
100
|
|
|
return $this->maxValue; |
101
|
2 |
|
} |
102
|
|
|
|
103
|
2 |
|
/** |
104
|
|
|
* @return int |
105
|
|
|
*/ |
106
|
|
|
public function getCount(): int |
107
|
|
|
{ |
108
|
|
|
return $this->count; |
109
|
10 |
|
} |
110
|
|
|
|
111
|
10 |
|
/** |
112
|
|
|
* @return int |
113
|
|
|
*/ |
114
|
|
|
public function getMinValueIteration(): int |
115
|
|
|
{ |
116
|
|
|
return $this->minValueIteration; |
117
|
12 |
|
} |
118
|
|
|
|
119
|
12 |
|
/** |
120
|
|
|
* @return int |
121
|
|
|
*/ |
122
|
|
|
public function getMaxValueIteration(): int |
123
|
|
|
{ |
124
|
|
|
return $this->maxValueIteration; |
125
|
9 |
|
} |
126
|
|
|
|
127
|
9 |
|
/** |
128
|
|
|
* @return float |
129
|
|
|
*/ |
130
|
|
|
public function getElapsed(): float |
131
|
|
|
{ |
132
|
|
|
return $this->elapsed; |
133
|
9 |
|
} |
134
|
|
|
|
135
|
9 |
|
/** |
136
|
|
|
* @return bool |
137
|
|
|
*/ |
138
|
|
|
public function isNotStopped(): bool |
139
|
|
|
{ |
140
|
|
|
return !$this->stopped; |
141
|
12 |
|
} |
142
|
|
|
|
143
|
12 |
|
/** |
144
|
|
|
* @return float |
145
|
|
|
*/ |
146
|
|
|
public function getCreation(): float |
147
|
|
|
{ |
148
|
|
|
return $this->creation; |
149
|
11 |
|
} |
150
|
|
|
|
151
|
11 |
|
/** |
152
|
|
|
* @return float |
153
|
|
|
*/ |
154
|
|
|
public function getPrevious(): float |
155
|
|
|
{ |
156
|
|
|
return $this->previous; |
157
|
11 |
|
} |
158
|
|
|
} |
159
|
|
|
|