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 1212class Timing
1313{
1414
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+
1529 /**
1630 * The start time of the run in microseconds.
1731 *
@@ -67,15 +81,15 @@ public static function getDuration()
6781 public static function getHumanReadableDuration ($ duration )
6882 {
6983 $ 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 );
7387 $ timeString = $ mins .' mins ' ;
7488 if ($ secs >= 0.01 ) {
7589 $ timeString .= ", $ secs secs " ;
7690 }
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 ' ;
7993 } else {
8094 $ timeString = round ($ duration ).'ms ' ;
8195 }
You can’t perform that action at this time.
0 commit comments