1 | <?php |
||
17 | class Benchmark |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * array containing the start time for the timers |
||
22 | */ |
||
23 | private static $start_times; |
||
|
|||
24 | |||
25 | /** |
||
26 | * array containing all the timer'd times, which can be outputted via show_times() |
||
27 | */ |
||
28 | private static $times = array(); |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | protected static $memory_usage = array(); |
||
34 | |||
35 | |||
36 | |||
37 | /** |
||
38 | * whether to benchmark code or not |
||
39 | */ |
||
40 | public static function doNotRun() |
||
44 | |||
45 | |||
46 | |||
47 | /** |
||
48 | * resetTimes |
||
49 | */ |
||
50 | public static function resetTimes() |
||
54 | |||
55 | |||
56 | |||
57 | /** |
||
58 | * Add Benchmark::startTimer() before a block of code you want to measure the performance of |
||
59 | * |
||
60 | * @param null $timer_name |
||
61 | */ |
||
62 | public static function startTimer($timer_name = null) |
||
70 | |||
71 | |||
72 | |||
73 | /** |
||
74 | * Add Benchmark::stopTimer() after a block of code you want to measure the performance of |
||
75 | * |
||
76 | * @param string $timer_name |
||
77 | */ |
||
78 | public static function stopTimer($timer_name = '') |
||
92 | |||
93 | |||
94 | |||
95 | /** |
||
96 | * Measure the memory usage by PHP so far. |
||
97 | * |
||
98 | * @param string $label The label to show for this time eg "Start of calling Some_Class::some_function" |
||
99 | * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called |
||
100 | * @return void |
||
101 | */ |
||
102 | public static function measureMemory($label, $output_now = false) |
||
113 | |||
114 | |||
115 | |||
116 | /** |
||
117 | * will display the benchmarking results at shutdown |
||
118 | * |
||
119 | * @return void |
||
120 | */ |
||
121 | public static function displayResultsAtShutdown() |
||
130 | |||
131 | |||
132 | |||
133 | /** |
||
134 | * displayResults |
||
135 | * |
||
136 | * @param bool $echo |
||
137 | * @return string |
||
138 | */ |
||
139 | public static function displayResults($echo = true) |
||
183 | |||
184 | |||
185 | |||
186 | /** |
||
187 | * Converts a measure of memory bytes into the most logical units (eg kb, mb, etc) |
||
188 | * |
||
189 | * @param int $size |
||
190 | * @return string |
||
191 | */ |
||
192 | public static function convert($size) |
||
197 | |||
198 | |||
199 | |||
200 | /** |
||
201 | * @param string $timer_name |
||
202 | * @param float $total_time |
||
203 | * @return string |
||
204 | */ |
||
205 | public static function formatTime($timer_name, $total_time) |
||
243 | |||
244 | |||
245 | |||
246 | } |
||
247 |
This check marks private properties in classes that are never used. Those properties can be removed.