diff --git a/laravel/helpers.php b/laravel/helpers.php index 07f9940a..b45fd9d2 100644 --- a/laravel/helpers.php +++ b/laravel/helpers.php @@ -580,4 +580,16 @@ 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]; } \ No newline at end of file diff --git a/laravel/profiling/profiler.php b/laravel/profiling/profiler.php index 9b6edfef..c8f069ae 100644 --- a/laravel/profiling/profiler.php +++ b/laravel/profiling/profiler.php @@ -14,7 +14,7 @@ class Profiler { * @var array */ protected static $data = array('queries' => array(), 'logs' => array()); - + /** * Get the rendered contents of the Profiler. * @@ -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); } } diff --git a/laravel/profiling/template.blade.php b/laravel/profiling/template.blade.php index 0b0ffef8..32c430a6 100755 --- a/laravel/profiling/template.blade.php +++ b/laravel/profiling/template.blade.php @@ -61,6 +61,8 @@ @endif +
  • Time {{ $time }}ms
  • +
  • Memory {{ $memory }} ({{ $memory_peak }})
  • ×