File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change 12
12
class Timing
13
13
{
14
14
15
+ /**
16
+ * Number of milliseconds in a minute.
17
+ *
18
+ * @var int
19
+ */
20
+ const MINUTE_IN_MS = 60000 ;
21
+
22
+ /**
23
+ * Number of milliseconds in a second.
24
+ *
25
+ * @var int
26
+ */
27
+ const SECOND_IN_MS = 1000 ;
28
+
15
29
/**
16
30
* The start time of the run in microseconds.
17
31
*
@@ -67,15 +81,15 @@ public static function getDuration()
67
81
public static function getHumanReadableDuration ($ duration )
68
82
{
69
83
$ timeString = '' ;
70
- if ($ duration >= 60000 ) {
71
- $ mins = floor ($ duration / 60000 );
72
- $ secs = round ((fmod ($ duration , 60000 ) / 1000 ), 2 );
84
+ if ($ duration >= self :: MINUTE_IN_MS ) {
85
+ $ mins = floor ($ duration / self :: MINUTE_IN_MS );
86
+ $ secs = round ((fmod ($ duration , self :: MINUTE_IN_MS ) / self :: SECOND_IN_MS ), 2 );
73
87
$ timeString = $ mins .' mins ' ;
74
88
if ($ secs >= 0.01 ) {
75
89
$ timeString .= ", $ secs secs " ;
76
90
}
77
- } else if ($ duration >= 1000 ) {
78
- $ timeString = round (($ duration / 1000 ), 2 ).' secs ' ;
91
+ } else if ($ duration >= self :: SECOND_IN_MS ) {
92
+ $ timeString = round (($ duration / self :: SECOND_IN_MS ), 2 ).' secs ' ;
79
93
} else {
80
94
$ timeString = round ($ duration ).'ms ' ;
81
95
}
You can’t perform that action at this time.
0 commit comments