Add detailed memory usage measurement for code blocks in Laravel Debugbar
This package was cloned from Amir Irfan's iffifan/laravel-debugbar-memory repo. I made some improvements by cloning because I saw that he did not contribute to the project for a long time. Thank him for publishing this package.
composer require sustartx/laravel-debugbar-memory --dev
"require-dev": {
"sustartx/laravel-debugbar-memory": "*"
},
"extra": {
"laravel": {
"dont-discover": [
"sustartx/laravel-debugbar-memory"
]
}
},
// Debugbar
if (env('DEBUGBAR_ENABLE', false)){
// $this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
$this->app->register(\SuStartX\MemoryDebugbar\Providers\MemoryDebugbarServiceProvider::class);
// $this->app->alias('Debugbar', \Barryvdh\Debugbar\Facades\Debugbar::class);
}
After successful installation you should see Memory
tab in your Debugbar
Let's calculate memory usage of a while loop with helper methods
start_memory_measure('Some Loop');
$a = 0;
$b = 'X';
while ($a < 10000000) {
$b .= 'X';
++$a;
}
stop_memory_measure('Some Loop');
Memory calculation will be updated like this:
Just add
'memory_details' => false, //Display memory details
in config/debugbar.php