Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jclaveau/phpunit-profile-asserts
Provides asserts against memory usage and execution time for PHPUnit
https://github.com/jclaveau/phpunit-profile-asserts
Last synced: 2 months ago
JSON representation
Provides asserts against memory usage and execution time for PHPUnit
- Host: GitHub
- URL: https://github.com/jclaveau/phpunit-profile-asserts
- Owner: jclaveau
- License: mit
- Created: 2018-07-13T08:41:34.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-13T14:37:57.000Z (over 6 years ago)
- Last Synced: 2024-09-27T21:41:03.212Z (3 months ago)
- Language: PHP
- Homepage:
- Size: 14.6 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# phpunit-profile-asserts
This lib provides asserts against execution time and memory usage.
It also provides a StopwatchListener based on the Stopwatch component of Symfony.[![Build Status](https://travis-ci.org/jclaveau/phpunit-profile-asserts.svg?branch=master)](https://travis-ci.org/jclaveau/phpunit-profile-asserts)
## Installation
phpunit-profile-asserts is installable via [Composer](http://getcomposer.org)
and should be added as a `require-dev` dependency:composer require --dev jclaveau/phpunit-profile-asserts
## Usage
Enable by adding the following code to your project's `phpunit.xml` file:
```xml
...
```
```php
class SomeTestCase extends \PHPUnit_Framework_TestCase
{
use \JClaveau\PHPUnit\Framework\UsageConstraintTrait; // adds the asserts methods/**
*/
public function test_usages()
{
// ...$this->assertExecutionTimeBelow(1.5); // seconds
$this->assertMemoryUsageBelow('1M');// This trait also provides two methods to help knowing the current
// memory usage and duration
$this->getMemoryUsage();
$this->getExecutionTime();
}}
```## TODO
+ PHP 7 implementation (find an elegant way to support PHP 5 and 7 together)
+ Integrate SpeedTrap and adds MemoryTrap
+ Investigate xhprof integration and asserts on number of calls / execution time of specific methods/functions## Inspiration
+ https://github.com/usernam3/phpunit_stopwatch_annotations
+ https://github.com/johnkary/phpunit-speedtrap## License
phpunit-profile-asserts is available under the MIT License.