A simple helper for profiling async requests.
This report shows all the requests on a global timeline (example).
If you want to profile Guzzle's concurrency feature, then the execution flow report can help you a lot. It arranges all the requests by virtual "threads", so you are able to see (for example) how good the resource utilization is. An example report.
Install as usual, with Composer: composer require --dev alexeyshockov/guzzle-timeline-middleware
Just add appropriate middleware to your stack:
$handler = HandlerStack::create();
// For basic timeline report
$handler->push(TimelineReporter::middleware(__DIR__ . '/timeline.html'), 'timeline_report');
// For execution flow report
$handler->push(ExecutionFlowTimelineReporter::middleware(__DIR__ . '/ex_flow.html'), 'ex_flow_report');
$client = new \GuzzleHttp\Client([
'handler' => $handler,
]);
If you profile a long living process with a lot of HTTP requests, it's possible to split the report into chunks. Just
use ${NUMBER}
placeholder in your report file name template and pass the max number of entries per report chunk.
$handler = HandlerStack::create();
$handler->push(TimelineReporter::middleware(__DIR__ . '/timeline_${NUMBER}.html', null, 250), 'timeline_report');
$client = new \GuzzleHttp\Client([
'handler' => $handler,
]);