Created
March 17, 2020 17:24
-
-
Save theofidry/ccdc1e26f36aff043b6c11d0d47fd4d3 to your computer and use it in GitHub Desktop.
Infection profiling with Blackfire SDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
use Blackfire\Client; | |
use Blackfire\Profile\Configuration; | |
use Symfony\Component\Console\Input\ArgvInput; | |
use Symfony\Component\Console\Output\ConsoleOutput; | |
use Symfony\Component\Console\Style\SymfonyStyle; | |
use function Safe\sprintf; | |
require_once __DIR__.'/../../../vendor/autoload.php'; | |
$input = new ArgvInput(); | |
$output = new ConsoleOutput(); | |
$io = new SymfonyStyle($input, $output); | |
$blackfire = new Client(); | |
$samples = 1; | |
$config = new Configuration(); | |
$config->setMetadata('profile', 'Tracing'); | |
$config->setMetadata('skip_timeline', 'false'); | |
$config->setSamples($samples); | |
$probe = $blackfire->createProbe($config, false); | |
$io->section('Tracing profiling'); | |
$io->progressStart($samples); | |
for ($i = 1; $i <= $samples; $i++) { | |
// Enable instrumentation | |
$probe->enable(); | |
echo 'hello'; | |
// Finish the profile so that another one will be taken on the next loop iteration | |
$probe->close(); | |
$io->progressAdvance(); | |
} | |
$io->progressFinish(); | |
$profile = $blackfire->endProbe($probe); | |
$io->success('Done'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment