Installation:
git clone [email protected]:936078e0b626122aee71a242539dfa47.git log-demo
cd log-demo
composer install
php index.php
Installation:
git clone [email protected]:936078e0b626122aee71a242539dfa47.git log-demo
cd log-demo
composer install
php index.php
{ | |
"name": "wowo/log-demo", | |
"type": "project", | |
"require": { | |
"monolog/monolog": "^2.0" | |
}, | |
"authors": [ | |
{ | |
"name": "Wojciech Sznapka", | |
"email": "[email protected]" | |
} | |
] | |
} |
<?php | |
require __DIR__.'/vendor/autoload.php'; | |
use Monolog\Logger; | |
use Monolog\Handler\StreamHandler; | |
use Monolog\Processor\MemoryPeakUsageProcessor; | |
use Monolog\Processor\MemoryUsageProcessor; | |
$log = new Logger(basename(__DIR__)); | |
$log | |
->pushHandler(new StreamHandler('php://stdout', Logger::INFO)) | |
->pushProcessor(new MemoryUsageProcessor()) | |
->pushProcessor(new MemoryPeakUsageProcessor()); | |
$log->info('Starting'); | |
$randomNumbers = []; | |
for ($i = 0; $i < 1234567; $i++) { | |
$randomNumbers[] = rand(); | |
} | |
$log->info('Got 1st batch of numbers'); | |
unset($randomNumbers); | |
$randomNumbers = []; | |
$log->info('Erased'); | |
for ($i = 0; $i < 2 * 1234567; $i++) { | |
$randomNumbers[] = rand(); | |
} | |
$log->info('Got 2nd batch of numbers'); | |
echo '¯\_(ツ)_/¯' . PHP_EOL; |