PHP code example of eliashaeussler / scope-profiler
1. Go to this page and download the library: Download eliashaeussler/scope-profiler library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
eliashaeussler / scope-profiler example snippets
use Eliashaeussler\ScopeProfiler;
// Option A: Shared instance (singleton)
$profiler = ScopeProfiler\ScopeProfiler::get();
// Option B: New instance
$profiler = new ScopeProfiler\ScopeProfiler();
$scope = new ScopeProfiler\Scope('Crawling the internet');
$profiler->pushScope($scope);
$profiler->pullScope($scope);
$task = new SomeLongRunningTask();
// Option A: Automatic start and stop
$result = $scope->run($task->execute(...));
// Option B: Manual start, execute, and stop
$scope->start();
$result = $task->execute();
$scope->stop();
$measurement = $scope->measure();
$duration = $measurement->duration; // float
$memoryUsage = $measurement->memoryUsage; // int
$memoryPeak = $measurement->memoryPeak; // int
$formattedMeasurement = $measurement->format(); // Crawling the internet took 7 min and consumed 8 GiB of memory (peak at 16 GiB)
$formattedDuration = $measurement->formatDuration(); // 7 min
$formattedMemoryUsage = $measurement->formatMemoryUsage(); // 8 GiB
$formattedMemoryPeak = $measurement->formatMemoryPeak(); // 16 GiB
$scopes = $profiler->releaseScopes();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.