| 1: | <?php | 
| 2: |  | 
| 3: |  | 
| 4: |  | 
| 5: |  | 
| 6: |  | 
| 7: |  | 
| 8: |  | 
| 9: |  | 
| 10: |  | 
| 11: |  | 
| 12: |  | 
| 13: |  | 
| 14: |  | 
| 15: |  | 
| 16: |  | 
| 17: |  | 
| 18: |  | 
| 19: |  | 
| 20: |  | 
| 21: |  | 
| 22: |  | 
| 23: |  | 
| 24: |  | 
| 25: |  | 
| 26: | namespace Kint\Renderer\Rich; | 
| 27: |  | 
| 28: | use Kint\Object\Representation\MicrotimeRepresentation; | 
| 29: | use Kint\Object\Representation\Representation; | 
| 30: | use Kint\Utils; | 
| 31: |  | 
| 32: | class MicrotimePlugin extends Plugin implements TabPluginInterface | 
| 33: | { | 
| 34: | public function renderTab(Representation $r) | 
| 35: | { | 
| 36: | if (!($r instanceof MicrotimeRepresentation)) { | 
| 37: | return false; | 
| 38: | } | 
| 39: |  | 
| 40: | $out = $r->getDateTime()->format('Y-m-d H:i:s.u'); | 
| 41: | if (null !== $r->lap) { | 
| 42: | $out .= '<br><b>SINCE LAST CALL:</b> <span class="kint-microtime-lap">'.\round($r->lap, 4).'</span>s.'; | 
| 43: | } | 
| 44: | if (null !== $r->total) { | 
| 45: | $out .= '<br><b>SINCE START:</b> '.\round($r->total, 4).'s.'; | 
| 46: | } | 
| 47: | if (null !== $r->avg) { | 
| 48: | $out .= '<br><b>AVERAGE DURATION:</b> <span class="kint-microtime-avg">'.\round($r->avg, 4).'</span>s.'; | 
| 49: | } | 
| 50: |  | 
| 51: | $bytes = Utils::getHumanReadableBytes($r->mem); | 
| 52: | $out .= '<br><b>MEMORY USAGE:</b> '.$r->mem.' bytes ('.\round($bytes['value'], 3).' '.$bytes['unit'].')'; | 
| 53: | $bytes = Utils::getHumanReadableBytes($r->mem_real); | 
| 54: | $out .= ' (real '.\round($bytes['value'], 3).' '.$bytes['unit'].')'; | 
| 55: |  | 
| 56: | $bytes = Utils::getHumanReadableBytes($r->mem_peak); | 
| 57: | $out .= '<br><b>PEAK MEMORY USAGE:</b> '.$r->mem_peak.' bytes ('.\round($bytes['value'], 3).' '.$bytes['unit'].')'; | 
| 58: | $bytes = Utils::getHumanReadableBytes($r->mem_peak_real); | 
| 59: | $out .= ' (real '.\round($bytes['value'], 3).' '.$bytes['unit'].')'; | 
| 60: |  | 
| 61: | return '<pre data-kint-microtime-group="'.$r->group.'">'.$out.'</pre>'; | 
| 62: | } | 
| 63: |  | 
| 64: | public static function renderJs() | 
| 65: | { | 
| 66: | return \file_get_contents(KINT_DIR.'/resources/compiled/microtime.js'); | 
| 67: | } | 
| 68: | } | 
| 69: |  |