JSON Output for Profiles
The Blackfire CLI tool supports a JSON output to ease the integration with other tools
What about integrating Blackfire into your own tools? As a first step, you can use the --json
option we’ve added recently to the Blackfire CLI tool.
When running Blackfire on the console to profile a script (blackfire run
) or to profile a web app or an HTTP API (blackfire curl
), you can ask for a JSON representation of the result via the --json
option:
$ blackfire run --json --slot 1 php -r 'echo "Hello Blackfire";' | json_pp { "label" : "", "id" : "31417068-adfa-4a6b-9585-9507e9b804ff", "envelope" : { "pmu" : 6336, "nw" : 0, "wt" : 283, "cpu" : 273, "io" : 10, "ct" : 1 }, "created_at" : "2015-05-19T03:33:40+0000", "_links" : { "graph_url" : { "href" : "https://blackfire.io/profiles/xxxx/graph" }, "self" : { "href" : "https://blackfire.io/api/v1/profiles/xxxx" } }, "updated_at" : "2015-05-19T03:33:40+0000", "status" : { "name" : "finished", "failure_reason" : null, "code" : 64, "updated_at" : "2015-05-19T03:33:40+0000" }, "arguments" : [] }
The resources consumed by your app are under the envelope
entry; keys are the dimension and here is their legend:
pmu
: Peak Memory Usage (in bytes);nw
: Network (in microseconds);wt
: Wall Clock Time (in microseconds);cpu
: CPU time (in microseconds);io
: I/O time (in microseconds).
By the way, recent versions of the blackfire run
and blackfire curl
commands also output a summary of the main costs to make it easy and fast to understand the resources consumed by your app:
$ blackfire run --slot 1 php -r 'echo "Hello Blackfire";' Hello Blackfire Blackfire Run completed Profile URL: https://blackfire.io/profiles/b3f9cee3-5bb7-4de0-9453-26baf4fe0e8d/graph Total time: 265 µs CPU time: 266 µs I/O: n/a Memory: 6.19 KB Network: n/a
Happy profiling!