Merge pull request #898 from franzliedke/patch-13
[Profiler] Display page rendering time & memory usage
This commit is contained in:
commit
da35e257fd
|
@ -581,3 +581,15 @@ function get_cli_option($option, $default = null)
|
|||
|
||||
return value($default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the human-readable file size (with proper units).
|
||||
*
|
||||
* @param int $size
|
||||
* @return string
|
||||
*/
|
||||
function get_file_size($size)
|
||||
{
|
||||
$units = array('Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB');
|
||||
return @round($size / pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$units[$i];
|
||||
}
|
|
@ -28,6 +28,9 @@ public static function render($response)
|
|||
// type applications, so we will not send anything in those scenarios.
|
||||
if ( ! Request::ajax())
|
||||
{
|
||||
static::$data['memory'] = get_file_size(memory_get_usage(true));
|
||||
static::$data['memory_peak'] = get_file_size(memory_get_peak_usage(true));
|
||||
static::$data['time'] = number_format((microtime(true) - LARAVEL_START) * 1000, 2);
|
||||
return render('path: '.__DIR__.'/template'.BLADE_EXT, static::$data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@
|
|||
@endif
|
||||
</a>
|
||||
</li>
|
||||
<li><a class="anbu-tab">Time <span class="anbu-count">{{ $time }}ms</span></a></li>
|
||||
<li><a class="anbu-tab">Memory <span class="anbu-count">{{ $memory }} ({{ $memory_peak }})</span></a></li>
|
||||
<li class="anbu-tab-right"><a id="anbu-hide" href="#">↦</a></li>
|
||||
<li class="anbu-tab-right"><a id="anbu-close" href="#">×</a></li>
|
||||
<li class="anbu-tab-right"><a id="anbu-zoom" href="#">⇅</a></li>
|
||||
|
|
Loading…
Reference in New Issue