Reports

PHPBench includes a reporting framework. Report generators provide report data which can subsequently be rendered by report renderer.

This guide will deal with generating reports and assume that the console renderer is used.

Generating Reports

To report after a benchmarking run:

phpbench run --report=aggregate

Multiple reports can be specified:

phpbench run --report=aggregate --report=env

The report command operates in a similar way but requires you to provide some data, either from XML dumps or by using a storage UUID or tag:

phpbench run --store
phpbench report --ref=latest --report=aggregate

For more information on storage see storage.

Configuring Reports

All reports can be configured either in the report configuration or directly on the command line using a simplified JSON encoded string instead of the report name:

To configure a report in phpbench.json:

{
    "runner.path": "NothingBench.php",
    "runner.executor": "debug",
    "report.generators": {
        "my-report": {
            "generator": "expression",
            "cols": [ "benchmark", "tag", "subject", "mean" ],
            "break": ["benchmark"]
        }
    }
}

Then run it with:

phpbench run --report=my-report

You can also configure reports directly from the command line using simplified JSON:

phpbench run --report='"generator": "expression", "cols": [ "benchmark", "tag", "subject", "mean" ], "break": ["benchmark"]'

In each case it is required to specify the generator key which corresponds to the registered name of the report generator.

You may also extend an existing report configuration:

phpbench run --report='extends: aggregate, break: ["benchmark", "set"]'

This will merge the given keys onto the configuration for the aggregate report.

Default Reports

aggregate

Shows aggregate details of each set of iterations:

+--------------+--------------+-----+------+-----+----------+----------+--------+
| benchmark    | subject      | set | revs | its | mem_peak | mode     | rstdev |
+--------------+--------------+-----+------+-----+----------+----------+--------+
| NothingBench | benchNothing | 0   | 1    | 1   | 100b     | 10.000μs | ±0.00% |
+--------------+--------------+-----+------+-----+----------+----------+--------+

It is uses the table generator, see Expression Report for more information.

default

The default report presents the result of each iteration:

{
    "runner.path": "NothingBench.php",
    "runner.executor": "debug",
    "runner.env_enabled_providers": ["test"],
    "report.generators": {
        "all": {
            "generator": "composite",
            "reports": [ "default", "aggregate", "env" ]
        }
    }
}

It is uses the table generator, see Expression Report for more information.

env

This report shows information about the environment that the benchmarks were executed in.

Suite E3X6AeMdP7L9E7E0X0A7McP1L8E1EdXbAbMbP7La xxxx-xx-xx xx-xx-xx
+----------+----------+-------+
| provider | key      | value |
+----------+----------+-------+
| test     | example1 | 1     |
| test     | example2 | 2     |
+----------+----------+-------+

Generator: Env.

Columns:

  • provider: Name of the environment provider (see PhpBench\Environment\Provider in the code for more information).
  • key: Information key.
  • value: Information value.

See the Environment reference for more information.

Note

The information available will differ depending on platform. For example, unit-sysload is unsurprisingly only available on UNIX platforms, where as the VCS field will appear only when a supported VCS system is being used.