Blackfire main use case is to profile HTTP requests like web pages, web service calls, or API calls.
Before starting profiling, check that you have Blackfire installed correctly on the server hosting the website you need to profile.
Profiling an HTTP request mean instrumenting the project's code, which incurs some overhead. Blackfire is apart from many other profilers because of two main differences:
You can easily profile HTTP requests from Google Chrome. This cookbook describes how to profile from the command line interface.
Profiling an HTTP request can easily be done on the command line thanks to the
blackfire utility that is bundled with the Blackfire Agent.
The easiest way to profile an HTTP request is to use the
blackfire utility. It accepts the same arguments and options as the regular
blackfire curl http://example.com/
You can get a list of options available for the
blackfire help curl
To get more accurate results, take several samples of the request via the
--samples option (we recommend you to use this option only for "safe" HTTP
requests like GET requests):
blackfire --samples 10 curl http://example.com/
At the end,
blackfire outputs the URL where the profile can be found (this
can be hidden by passing the
Create a reference profile by
blackfire --new-reference curl http://example.com/
Compare a profile to a reference profile by passing its
part of the output of the previous command or available on the web UI) via
blackfire --reference=7 curl http://example.com/
You can easily integrate Blackfire results into your own tools by using the
--json option to get a JSON representation of a profile:
blackfire --json curl http://example.com/
The resources consumed are available under the
keys are the cost dimensions:
Profiling non-GET requests or requests which need some specific HTTP headers is
as easy as any other requests as
blackfire curl supports all cURL options:
blackfire curl -XPOST http://example.com/
Blackfire automatically instruments your code, but sometimes, you might want to focus the profiling on only part of the code. That's possible when opting for manual instrumentation via the PHP SDK.
After instrumenting your code, use the
blackfire utility as above to
profile your application. When not using Blackfire, all calls are converted to