PHP code example of jclaveau / phpunit-profile-asserts
1. Go to this page and download the library: Download jclaveau/phpunit-profile-asserts library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jclaveau / phpunit-profile-asserts example snippets
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();
}
}
xml
<phpunit bootstrap="vendor/autoload.php">
...
<listeners>
<listener class="JClaveau\PHPUnit\Listener\StopwatchListener" />
</listeners>
</phpunit>