phpunit/php-timer
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The phpunit/php-timer is a highly useful stand-alone component that provides a utility class for timing purposes. Originally part of PHPUnit, this component has considerable functionality and it is beneficial for those who need to time certain processes within their PHP projects, perhaps for performance measurement or timing debugging actions.
To use the phpunit/php-timer, you first need to install the package via Composer. You can add this library as a local per-project dependency using the command composer require phpunit/php-timer
. If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency with the command composer require --dev phpunit/php-timer
.
Here is a basic example of using phpunit/php-timer for timing:
require __DIR__ . '/vendor/autoload.php';
use SebastianBergmann\Timer\Timer;
$timer = new Timer;
$timer->start();
foreach (\range(0, 100000) as $i) {
//...
}
$duration = $timer->stop();
var_dump($duration->asSeconds()); // Output the duration in seconds
PHPunit/php-timer also provides functionality to measure resource consumption and duration since PHP startup. For full code samples and usage examples, please refer to the Usage section in the supplied README.
The documentation for phpunit/php-timer can be found directly inline within the README.md file which is available in the root of the project's GitHub repository at https://github.com/sebastianbergmann/php-timer. This documentation provides all necessary details including installation instructions, basic usage examples, and detailed functionality descriptions.