Configuration

Unless overridden with the --config option, PHPBench will try to load its configuration from the current working directory. It will check for the existence each of the files phpbench.json and phpbench.json.dist in that order and use one if it exists.

{
    "$schema":"./vendor/phpbench/phpbench/phpbench.schema.json",
    "runner.bootstrap": "vendor/autoload.php",
    "runner.path": "path/to/benchmarks",
    "report.outputs": {
         "my_csv_output": {
             "extends": "delimited",
             "delimiter": ",",
         }
    },
    "report.generators": {
        "my_report": {
            "extends": "aggregate"
        }
    }
}

You can include more configuration files with the $include and $include-glob directives:

{
    "$include": ["path/to/config.json"],
    "$include-glob": ["path/to/*.json"],
}

Core

Extension class: PhpBench\Extension\CoreExtension

$schema

JSON schema location, e.g. ./vendor/phpbench/phpbench/phpbench.schema.json

Default: NULL

Types: ["string","null"]

core.debug

If enabled output debug messages (e.g. the commands being executed when running benchamrks). Same as -vvv

Default: false

Types: ["bool"]

core.extensions

List of additional extensions to enable

Default: []

Types: ["string[]"]

core.working_dir

Working directory to use

Default: /home/daniel/www/phpbench/phpbench

Types: ["string"]

core.config_path

Alternative path to a PHPBench configuration file (default is phpbench.json

Default: NULL

Types: ["string","null"]

core.profiles

Alternative configurations:

{
    "core.profiles": {
        "php8": {
            "runner.php_bin": "/bin/php8"
        }
    }
}

The named configuration will be merged with the default configuration, and can be used via:

$ phpbench run --profile=php8

Default: []

Types: ["array"]

Runner

Extension class: PhpBench\Extension\RunnerExtension

runner.annotations

Read metadata from annotations

Default: true

Types: ["bool"]

runner.annotation_import_use

Require that annotations be imported before use

Default: false

Types: ["bool"]

runner.attributes

Read metadata from PHP 8 attributes

Default: true

Types: ["bool"]

runner.bootstrap

Path to bootstrap (e.g. vendor/autoload.php)

Default: NULL

Types: ["string","null"]

runner.env_enabled_providers

Select which environment samplers to use

Default: ["sampler","git","opcache","php","uname","unix_sysload"]

Types: ["array"]

runner.env_samplers

Environment baselines (not to be confused with baseline comparisons when running benchmarks) are small benchmarks which run to sample the speed of the system (e.g. file I/O, computation etc). This setting enables or disables these baselines

Default: ["nothing","md5","file_rw"]

Types: ["array"]

runner.env_sampler_callables

Map of baseline callables (adds you to register a new environemntal baseline)

Default: []

Types: ["array"]

runner.executors

Add new executor configurations

Default: []

Types: ["array"]

runner.path

Path or paths to the benchmarks

Default: NULL

Types: ["string","array","null"]

runner.php_binary

Specify a PHP binary to use when executing out-of-band benchmarks, e.g. /usr/bin/php6, defaults to the version of PHP used to invoke PHPBench

Default: NULL

Types: ["string","null"]

runner.php_config

Map of PHP ini settings to use when executing out-of-band benchmarks

Default: []

Types: ["array"]

runner.php_disable_ini

Disable reading the default PHP configuration

Default: false

Types: ["bool"]

runner.php_wrapper

Wrap the PHP binary with this command (e.g. blackfire run)

Default: NULL

Types: ["string","null"]

runner.php_env

Key-value set of environment variables to pass to the PHP process

Default: NULL

Types: ["array","null"]

runner.progress

Default progress logger to use

Default: verbose

Types: ["string"]

runner.progress_summary_variant_format

Expression used to render the summary text default progress loggers

Default: label("Mo") ~ display_as_time(mode(variant.time.avg), coalesce(subject.time_unit,"time"), subject.time_precision, subject.time_mode) ~ " (" ~ rstdev(variant.time.avg) ~ ")"

Types: ["string"]

runner.progress_summary_baseline_format

When the a comparison benchmark is referenced, alternative expression used to render the summary text default progress loggers

Default: "[" ~ label("Mo") ~ display_as_time(mode(variant.time.avg), coalesce(subject.time_unit,"time"), subject.time_precision, subject.time_mode) ~ " vs. " ~ label("Mo") ~ display_as_time(mode(baseline.time.avg), coalesce(subject.time_unit,"time"), subject.time_precision, subject.time_mode) ~ "] " ~ percent_diff(mode(baseline.time.avg), mode(variant.time.avg), (rstdev(variant.time.avg) * 2)) ~ " (" ~ rstdev(variant.time.avg) ~ ")"

Types: ["string"]

runner.remote_script_path

PHPBench generates a PHP file for out-of-band benchmarks which is executed, this setting specifies the path to this file. When NULL a file in the systems temporary directory will be used

Default: NULL

Types: ["string","null"]

runner.remote_script_remove

If the generated file should be removed after it has been executed (useful for debugging)

Default: true

Types: ["bool"]

runner.assert

Default Assertions

Default: NULL

Types: ["null","string","array"]

runner.executor

Default executor

Default: NULL

Types: ["null","string"]

runner.format

Default Format

Default: NULL

Types: ["null","string"]

runner.iterations

Default Iterations

Default: NULL

Types: ["null","int","array"]

runner.output_mode

Default output mode

Default: NULL

Types: ["null","string"]

runner.time_unit

Default time unit

Default: NULL

Types: ["null","string"]

runner.retry_threshold

Default RetryThreshold

Default: NULL

Types: ["null","int","float"]

runner.revs

Default number of Revolutions

Default: NULL

Types: ["null","int","array"]

runner.timeout

Default Timeout

Default: NULL

Types: ["null","float","int"]

runner.warmup

Default Warm Up

Default: NULL

Types: ["null","int","array"]

runner.subject_pattern

Subject pattern (regex) to use when finding benchmarks

Default: ^bench

Types: ["string"]

runner.file_pattern

Consider file names matching this pattern to be benchmarks. NOTE: In 2.0 this will be set to *Bench.php

Default: NULL

Types: ["string","null"]

Report

Extension class: PhpBench\Extension\ReportExtension

report.generators

Report generator configurations, see Report Generators

Default: []

Types: ["array"]

report.outputs

Report renderer configurations, see Report Renderers

Default: []

Types: ["array"]

report.components

Component configurations, see Report Components

Default: []

Types: ["array"]

report.template_paths

List of paths to load templates from

Default: ["\/home\/daniel\/www\/phpbench\/phpbench\/lib\/Extension\/..\/..\/templates"]

Types: ["array"]

report.template_map

Namespace prefix to template path map for object rendering

Default: {"PhpBench\\Report\\Model":"html","PhpBench\\Expression\\Ast":"html\/node"}

Types: ["array"]

Expression

Extension class: PhpBench\Extension\ExpressionExtension

expression.syntax_highlighting

Enable syntax highlighting

Default: true

Types: ["bool"]

expression.theme

Select a theme to use

Default: solarized

Types: ["string"]

expression.memory_unit_prefix

By default use decimal (1kb = 1000 bytes) or binary (1KiB = 1024 bytes) when displaying memory

Default: decimal

Types: ["string"]

Allowed values: ["binary","decimal"]

expression.strip_tailing_zeros

Do not display meaningless zeros after the decimal place

Default: false

Types: ["bool"]

Storage

Extension class: PhpBench\Extension\StorageExtension

storage.driver

Storage driver to use

Default: xml

Types: ["string"]

storage.xml_storage_path

Path to store benchmark runs when they are stored with --store or --tag=foo

Default: .phpbench/storage

Types: ["string"]

storage.store_binary

If binary and serialized parameter values should be stored

Default: false

Types: ["boolean"]

XDebug

Extension class: PhpBench\Extensions\XDebug\XDebugExtension

xdebug.command_handler_output_dir

Output directory for generated XDebug profiles

Default: .phpbench/xdebug-profile

Types: ["string"]

Console

Extension class: PhpBench\Extension\ConsoleExtension

console.ansi

Enable or disable ANSI control characters (e.g. console colors)

Default: NULL

Types: ["bool","null"]

console.disable_output

Disable output from both STDOUT and STDERR

Default: false

Types: ["bool"]

console.output_stream

Change the normal output stream - the output stream used for reports

Default: php://stdout

Types: ["string"]

console.error_stream

Change the error output stream - the output stream used for diagnostics (e.g. progress loggers use this stream)

Default: php://stderr

Types: ["string"]