1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class Kint_Renderer_Rich_Microtime extends Kint_Renderer_Rich_Plugin |
|
|
|
|
4
|
|
|
{ |
5
|
|
|
public function render($r) |
|
|
|
|
6
|
|
|
{ |
7
|
|
|
if (!($r instanceof Kint_Object_Representation_Microtime)) { |
8
|
|
|
return false; |
9
|
|
|
} |
10
|
|
|
|
11
|
|
|
list($usec, $sec) = explode(' ', $r->contents); |
12
|
|
|
|
13
|
|
|
// '@' is used to prevent the dreaded timezone not set error |
14
|
|
|
$out = @date('Y-m-d H:i:s', $sec).'.'.substr($usec, 2, 4); |
15
|
|
View Code Duplication |
if ($r->lap !== null) { |
|
|
|
|
16
|
|
|
$out .= "\n<b>SINCE LAST CALL:</b> <b class=\"kint-microtime-lap\">".round($r->lap, 4).'</b>s.'; |
17
|
|
|
} |
18
|
|
|
if ($r->total !== null) { |
19
|
|
|
$out .= "\n<b>SINCE START:</b> ".round($r->total, 4).'s.'; |
20
|
|
|
} |
21
|
|
View Code Duplication |
if ($r->avg !== null) { |
|
|
|
|
22
|
|
|
$out .= "\n<b>AVERAGE DURATION:</b> <span class=\"kint-microtime-avg\">".round($r->avg, 4).'</span>s.'; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
$unit = array('B', 'KB', 'MB', 'GB', 'TB'); |
26
|
|
|
|
27
|
|
|
$out .= "\n<b>MEMORY USAGE:</b> ".$r->mem.' bytes ('; |
28
|
|
|
$i = floor(log($r->mem, 1024)); |
29
|
|
|
$out .= round($r->mem / pow(1024, $i), 3).' '.$unit[$i].')'; |
30
|
|
|
$i = floor(log($r->mem_real, 1024)); |
31
|
|
|
$out .= ' (real '.round($r->mem_real / pow(1024, $i), 3).' '.$unit[$i].')'; |
32
|
|
|
|
33
|
|
|
if ($r->mem_peak !== null && $r->mem_peak_real !== null) { |
34
|
|
|
$out .= "\n<b>PEAK MEMORY USAGE:</b> ".$r->mem_peak.' bytes ('; |
35
|
|
|
$i = floor(log($r->mem_peak, 1024)); |
36
|
|
|
$out .= round($r->mem_peak / pow(1024, $i), 3).' '.$unit[$i].')'; |
37
|
|
|
$i = floor(log($r->mem_peak_real, 1024)); |
38
|
|
|
$out .= ' (real '.round($r->mem_peak_real / pow(1024, $i), 3).' '.$unit[$i].')'; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
return '<pre data-kint-microtime-group="'.$r->group.'">'.$out.'</pre>'; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public static function renderJs() |
45
|
|
|
{ |
46
|
|
|
return file_get_contents(KINT_DIR.'/resources/compiled/rich_microtime.js'); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.