PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 3.0.1
Defender Security – Malware Scanner, Login Security & Firewall v3.0.1
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / extra / php-codesniffer-php-token / Util / Timing.php

Timing.php in Defender Security – Malware Scanner, Login Security & Firewall 3.0.1, at src/extra/php-codesniffer-php-token/Util/Timing.php

87 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Timing functions for the run.
4 *
5 * @author Greg Sherwood <[email protected]>
6 * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7 * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8 */
9
10 namespace PHP_CodeSniffer\Util;
11
12 class Timing
13 {
14
15 /**
16 * The start time of the run.
17 *
18 * @var float
19 */
20 private static $startTime;
21
22 /**
23 * Used to make sure we only print the run time once per run.
24 *
25 * @var boolean
26 */
27 private static $printed = false;
28
29
30 /**
31 * Start recording time for the run.
32 *
33 * @return void
34 */
35 public static function startTiming()
36 {
37
38 self::$startTime = microtime(true);
39
40 }//end startTiming()
41
42
43 /**
44 * Print information about the run.
45 *
46 * @param boolean $force If TRUE, prints the output even if it has
47 * already been printed during the run.
48 *
49 * @return void
50 */
51 public static function printRunTime($force=false)
52 {
53 if ($force === false && self::$printed === true) {
54 // A double call.
55 return;
56 }
57
58 if (self::$startTime === null) {
59 // Timing was never started.
60 return;
61 }
62
63 $time = ((microtime(true) - self::$startTime) * 1000);
64
65 if ($time > 60000) {
66 $mins = floor($time / 60000);
67 $secs = round((($time % 60000) / 1000), 2);
68 $time = $mins.' mins';
69 if ($secs !== 0) {
70 $time .= ", $secs secs";
71 }
72 } else if ($time > 1000) {
73 $time = round(($time / 1000), 2).' secs';
74 } else {
75 $time = round($time).'ms';
76 }
77
78 $mem = round((memory_get_peak_usage(true) / (1024 * 1024)), 2).'MB';
79 echo "Time: $time; Memory: $mem".PHP_EOL.PHP_EOL;
80
81 self::$printed = true;
82
83 }//end printRunTime()
84
85
86 }//end class
87