@rollin
There are several ways to test performance in PHPUnit:
Example:
1 2 3 4 5 6 7 8 9 10 11 |
public function testPerformance() { $start = microtime(true); // Code block to be tested $end = microtime(true); $executionTime = $end - $start; $this->assertLessThanOrEqual(1, $executionTime); // Ensure execution time is less than or equal to 1 second } |
Example:
1 2 3 4 5 6 7 8 9 10 11 |
public function testPerformance() { // Code block to be tested $coverage = $this->getCodeCoverage(); // Get the code coverage instance $coverageData = $coverage->getData(); // Get the coverage data $codeCoveragePercentage = $coverageData->getPercentage(); // Calculate the code coverage percentage $this->assertGreaterThanOrEqual(80, $codeCoveragePercentage); // Ensure code coverage is at least 80% } |
Example:
1 2 3 4 5 6 7 |
/** * @blackfire */ public function testPerformance() { // Code block to be tested } |
Note: Blackfire requires additional setup and configuration. Refer to the Blackfire documentation for more details.
Whichever method you choose, it is important to establish a performance baseline by running the tests multiple times and comparing the results to identify any performance issues or regressions.