Commit 82411db8 authored by Bill Schaller's avatar Bill Schaller

Change DbalPerformanceTestListener to report timings in __destruct instead of endTestSuite.

parent 669c03d6
......@@ -16,24 +16,32 @@ class DbalPerformanceTestListener extends \PHPUnit_Framework_BaseTestListener
*/
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
// This listener only applies to performance tests.
if ($test instanceof \Doctrine\Tests\DbalPerformanceTestCase)
{
// Identify perf tests by class, method, and dataset
$class = str_replace('Doctrine\Tests\DBAL\Performance\\', '', get_class($test));
// Store timing data for each test in the order they were run.
$this->timings[$class . "::" . $test->getName(true)] = $test->getTime();
}
}
/**
* {@inheritdoc}
* Report performance test timings.
*
* Note: __destruct is used here because PHPUnit doesn't have a
* 'All tests over' hook.
*/
public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
public function __destruct()
{
if (!empty($this->timings)) {
print("\n");
// Report timings.
print("\n\nPerformance test results:\n\n");
foreach($this->timings as $test => $time) {
printf("%s: %6.3f\n", $test, $time);
printf("%s: %.3f\n", $test, $time);
}
$this->timings = [];
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment