Download the PHP package phauthentic/phpunit-execution-timing-extension without Composer
On this page you can find all versions of the php package phauthentic/phpunit-execution-timing-extension. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phauthentic/phpunit-execution-timing-extension
More information about phauthentic/phpunit-execution-timing-extension
Files in phauthentic/phpunit-execution-timing-extension
Package phpunit-execution-timing-extension
Short Description PHPUnit extension to track and report test execution times
License MIT
Informations about the package phpunit-execution-timing-extension
PHPUnit Execution Timing Extension
A PHPUnit extension that tracks and reports test execution times, helping you identify slow tests in your test suite.
Features
- Tracks execution time for each test
- Displays a summary of the slowest tests after test execution
- Configurable number of slowest tests to display
- Optional per-test timing output
- Color-coded output based on configurable thresholds (yellow for warnings, red for danger)
- Aligned column formatting for easy reading
- Compatible with PHPUnit 10, 11, and 12
Requirements
- PHP 8.1 or higher
- PHPUnit 10, 11, or 12
Installation
Install via Composer:
Configuration
Add the extension to your phpunit.xml.dist or phpunit.xml file:
Configuration Parameters
topN(default:10): Number of slowest tests to display in the summary reportshowIndividualTimings(default:false): Whether to display timing for each test as it runsshowFQCN(default:true): Whether to display fully qualified class names (FQCN) or just the class name. When set tofalse, only the class name without namespace will be shown (e.g.,MyTestClass::testMethodinstead ofPhauthentic\PHPUnit\ExecutionTiming\Tests\MyTestClass::testMethod)warningThreshold(default:1.0): Time in seconds at which tests will be colored yellow (warning). Tests with execution time >= this value will be highlighted.dangerThreshold(default:5.0): Time in seconds at which tests will be colored red (danger). Tests with execution time >= this value will be highlighted in red. Tests betweenwarningThresholdanddangerThresholdwill be colored yellow.
Usage
After running your tests, you'll see a summary report at the end showing the slowest tests. Tests are color-coded based on their execution time:
- Yellow: Tests that exceed the warning threshold (default: 1 second)
- Red: Tests that exceed the danger threshold (default: 5 seconds)
- Normal: Tests below the warning threshold
Note: The actual output will show ANSI color codes when viewed in a terminal that supports colors. The colors help quickly identify tests that may need optimization.
Example Output
With showIndividualTimings set to true, you'll also see timing for each test as it executes:
Example Configuration
Basic Configuration
With Individual Timings Enabled
With Custom Thresholds
This configuration will:
- Show yellow for tests taking 0.5 seconds or more
- Show red for tests taking 2.0 seconds or more
With Short Class Names (showFQCN disabled)
This configuration will display only the class name without the full namespace path, making the output more compact:
MyTestClass::testMethodinstead ofPhauthentic\PHPUnit\ExecutionTiming\Tests\MyTestClass::testMethod
How It Works
The extension subscribes to PHPUnit events:
- Test Preparation Started: Records the start time for each test
- Test Finished: Calculates duration and optionally displays it
- Execution Finished: Generates and displays the summary report
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright
Copyright (c) Florian Krämer (https://florian-kraemer.net)