Download the PHP package teqneers/phpunit-stopwatch without Composer
On this page you can find all versions of the php package teqneers/phpunit-stopwatch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download teqneers/phpunit-stopwatch
More information about teqneers/phpunit-stopwatch
Files in teqneers/phpunit-stopwatch
Package phpunit-stopwatch
Short Description Extension to measure and analyse any part of your code in order to detect performance issues using phpunit/phpunit.
License MIT
Homepage https://github.com/teqneers/phpunit-stopwatch
Informations about the package phpunit-stopwatch
phpunit-stopwatch
Stopwatch is an essential phpunit/phpunit
extension for performance
analysis!
Gain invaluable insights into your code's execution time and call frequency during test runs. The extension is designed to elevate your code performance analysis. Track the execution time and frequency of any marked code segments to address performance bottlenecks with precision. You can identify performance bottlenecks (e.g., database cleanups or setup) or just monitor them over time. The extension will generate stopwatch reports for each test as well as a summary report at the end of the test run.
This project provides a composer
package and
a Phar archive.
The extension is compatible with the following versions of phpunit/phpunit
:
Once you've added some measurement points to your code, the extension will stop watch and count them. The results are displayed for each test and as a total report at the end of the test run.
Here is an example of how the output of a single test class might look:
And at the end of the test run, you will get a summary of all stopwatches used, and it is going to look like this:
Usage
Stopwatch is very easy to use. A single line of code wrapped around the code you want to measure is all it takes.
For instance, let's say your tests are pretty slow, but you don't know who's the culprit? You suspect that it might be the database setup that has to be done for each and every test. Simply wrap the suspected code block as follows:
Should the test, setup, teardown, or other relevant methods execute this code, Stopwatch will seamlessly measure its execution time and count, and will present the results within the test output.
Installation
Installation with composer
Run
to install teqneers/phpunit-stopwatch
as a composer
package.
Installation as Phar
Download phpunit-stopwatch.phar
from
the latest release.
Usage
Bootstrapping the extension
Before the extension can detect slow tests in phpunit/phpunit
, you need to bootstrap it. The bootstrapping mechanism
depends on the version of phpunit/phpunit
you are using.
Bootstrapping the extension as a composer
package
To bootstrap the extension as a composer
package when using
phpunit/phpunit:^10.0.0
phpunit/phpunit:^11.0.0
adjust your phpunit.xml
configuration file and configure the
Bootstrapping the extension as a PHAR
To bootstrap the extension as a PHAR when using
phpunit/phpunit:^10.1.0
phpunit/phpunit:^11.0.0
adjust your phpunit.xml
configuration file and configure the
extensionsDirectory
attribute and theextensions
element onphpunit/phpunit:^10.0.0
extensionsDirectory
attribute and theextensions
element onphpunit/phpunit:^11.0.0
Configuring the extension
So far, there are no configuration settings for this extension.
Running tests
When you have bootstrapped the extension, you can run your tests as usually. E.g.:
When the extension is used somewhere in your code, it will give you a report:
License
This project uses the MIT license.
Credits
This package is inspired by ergebnis/phpunit-slow-test-detector
.
All versions of phpunit-stopwatch with dependencies
phpunit/phpunit Version ^10.1.0 || ^11.0.0
psr/clock Version ^1.0.0
symfony/clock Version ^6.4.0 || ^7.0.0