Made timing code for test runner more accurate (includes initial db build):

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@84970 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-08-21 03:02:43 +00:00
parent 4ee62ae7eb
commit 5829c86947
2 changed files with 6 additions and 3 deletions

View File

@ -35,9 +35,6 @@ class CliTestReporter extends SapphireTestReporter {
echo "Maximum memory usage: " . number_format(memory_get_peak_usage()/(1024*1024), 1) . "M\n\n";
}
$totalTime = array_sum($this->testSpeeds);
echo "Total time: " . round($totalTime,3) . " seconds\n";
// Use sake dev/tests/all --showslow to show slow tests
if((isset($_GET['args']) && is_array($_GET['args']) && in_array('--showslow', $_GET['args'])) || isset($_GET['showslow'])) {
$avgSpeed = round(array_sum($this->testSpeeds) / count($this->testSpeeds), 3);

View File

@ -172,6 +172,8 @@ class TestRunner extends Controller {
* @param boolean $coverage
*/
function runTests($classList, $coverage = false) {
$startTime = microtime(true);
// XDEBUG seem to cause problems with test execution :-(
if(function_exists('xdebug_disable')) xdebug_disable();
@ -231,6 +233,10 @@ class TestRunner extends Controller {
if(!Director::is_cli()) echo '<div class="trace">';
$reporter->writeResults();
$endTime = microtime(true);
if(Director::is_cli()) echo "\n\nTotal time: " . round($endTime-$startTime,3) . " seconds\n";
else echo "<p>Total time: " . round($endTime-$startTime,3) . " seconds</p>\n";
if(!Director::is_cli()) echo '</div>';
// Put the error handlers back