LinuxCommandLibrary

blackfire

Profile PHP applications performance

TLDR

Initialize and configure the Blackfire client

$ blackfire config
copy

Launch the Blackfire agent
$ blackfire agent
copy

Launch the Blackfire agent on a specific socket
$ blackfire agent --socket="[tcp://127.0.0.1:8307]"
copy

Run the profiler on a specific program
$ blackfire run [php path/to/file.php]
copy

Run the profiler and collect 10 samples
$ blackfire --samples 10 run [php path/to/file.php]
copy

Run the profiler and output results as JSON
$ blackfire --json run [php path/to/file.php]
copy

Upload a profiler file to the Blackfire web service
$ blackfire upload [path/to/file]
copy

View the status of profiles on the Blackfire web service
$ blackfire status
copy

SYNOPSIS

blackfire command [options]

PARAMETERS

profile
    Initiates a profiling session for a specified URL or command.

probe
    Starts a low-overhead performance monitoring agent.

status
    Displays the status of the Blackfire agent.

config
    Manages Blackfire configuration.

--help
    Displays help information.

--version
    Displays the version number.

DESCRIPTION

Blackfire is a performance analysis tool designed specifically for PHP applications. It allows developers and operations teams to profile code, identify bottlenecks, and optimize application performance. The `blackfire` command-line tool interacts with the Blackfire.io service to initiate profiling sessions, collect performance data, and view results.

It works by injecting a profiler agent into the PHP process, collecting data on function calls, memory usage, and CPU time. This data is then uploaded to the Blackfire.io service for analysis and visualization. The command can be used to profile web requests, CLI scripts, and background processes. Blackfire offers features like call graphs, flame graphs, and automated performance tests to aid in identifying and resolving performance issues. It helps prevent performance regressions during development and deployment, leading to faster, more efficient PHP applications.

AUTHENTICATION

The `blackfire` command-line tool requires authentication with the Blackfire.io service using an environment variable or configuration file. You can use the BLACKFIRE_CLIENT_ID and BLACKFIRE_CLIENT_TOKEN environment variables to configure authentication.

PROFILING MODES

Blackfire supports different profiling modes, including sampling and tracing. Sampling provides a statistical overview of performance, while tracing captures every function call for detailed analysis. The appropriate mode depends on the specific performance issue being investigated.

CONFIGURATION FILES

The behavior of the `blackfire` command can be customized using configuration files. These files allow you to specify default options, define custom probes, and configure integration with CI systems.

HISTORY

Blackfire was developed by SensioLabs, the company behind the Symfony PHP framework. It emerged as a commercial solution to address the need for comprehensive PHP profiling and performance monitoring. Initially, it was available as a paid service with both free and premium tiers. Over time, Blackfire has evolved with features to support various PHP environments and frameworks, including integrations with continuous integration (CI) systems. The `blackfire` command-line tool serves as the primary interface for interacting with the Blackfire.io service and managing profiling sessions. Its usage grew alongside the adoption of Blackfire within the PHP development community, particularly among teams focused on optimizing application performance and identifying bottlenecks.

SEE ALSO

perf(1), strace(1)

Copied to clipboard