takigawaakinori / phpunit-profiler
A PHPUnit extension that profiles and reports the slowest tests
Package info
github.com/takigawaakinori/phpunit-profiler
Type:phpunit-extension
pkg:composer/takigawaakinori/phpunit-profiler
v0.2.0
2026-04-16 15:11 UTC
Requires
- php: ^8.1
- phpunit/phpunit: ^10.0 || ^11.0 || ^12.0 || ^13.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^1.0 || ^2.0
This package is auto-updated.
Last update: 2026-05-24 16:58:54 UTC
README
A PHPUnit extension that profiles test execution time and reports the slowest tests.
Supports PHPUnit 10, 11, 12, and 13.
日本語版はこちら: README.ja.md
Installation
composer require --dev takigawaakinori/phpunit-profiler
Usage
Add the extension to your phpunit.xml (or phpunit.xml.dist):
<extensions> <bootstrap class="TakigawaAkinori\PhpunitProfiler\TestProfilerExtension"/> </extensions>
Configuration
You can customize the extension behavior by adding <parameter> elements:
<extensions> <bootstrap class="TakigawaAkinori\PhpunitProfiler\TestProfilerExtension"> <parameter name="showTopN" value="false"/> <parameter name="topCount" value="50"/> <parameter name="showPareto" value="true"/> <parameter name="slowThreshold" value="1.0"/> <parameter name="jsonOutput" value=".test-profile-result.json"/> </bootstrap> </extensions>
| Parameter | Type | Default | Description |
|---|---|---|---|
showTopN |
bool | true |
Show the top N slowest tests list. Set to false to hide |
topCount |
int | 20 |
Number of slowest tests to display |
showPareto |
bool | false |
Show Pareto analysis (top 20% of tests and their share of total execution time) |
slowThreshold |
float | (disabled) | Show tests slower than the specified threshold in seconds |
jsonOutput |
string | (disabled) | File path to export all test durations as JSON |
Invalid Parameter Values
topCount: If the value is non-numeric or less than1, it falls back to the default20.slowThreshold: If the value is non-numeric, threshold filtering is disabled.showTopN/showPareto: These are string-based flags. Usetrueorfalseexactly.
Output Examples
After running your tests, you'll see output like:
Top 20 Slowest Tests:
--------------------------------------------------------------------------------
1. 5.032s Tests\Feature\ExampleTest::test_heavy_operation
2. 3.210s Tests\Feature\ExampleTest::test_api_call
3. 0.523s Tests\Unit\ExampleTest::test_calculation
--------------------------------------------------------------------------------
Requirements
- PHP 8.1+
- PHPUnit 10.0+
License
MIT