From 5829c869472187664462305445d5fa5e48d5d64a Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Fri, 21 Aug 2009 03:02:43 +0000 Subject: [PATCH] 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 --- dev/CliTestReporter.php | 3 --- dev/TestRunner.php | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dev/CliTestReporter.php b/dev/CliTestReporter.php index e947a7034..30f8f7690 100644 --- a/dev/CliTestReporter.php +++ b/dev/CliTestReporter.php @@ -34,9 +34,6 @@ class CliTestReporter extends SapphireTestReporter { if(function_exists('memory_get_peak_usage')) { 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'])) { diff --git a/dev/TestRunner.php b/dev/TestRunner.php index 98ae3ad0a..075a874a3 100644 --- a/dev/TestRunner.php +++ b/dev/TestRunner.php @@ -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(); @@ -230,6 +232,10 @@ class TestRunner extends Controller { if(!Director::is_cli()) echo '
'; $reporter->writeResults(); + + $endTime = microtime(true); + if(Director::is_cli()) echo "\n\nTotal time: " . round($endTime-$startTime,3) . " seconds\n"; + else echo "

Total time: " . round($endTime-$startTime,3) . " seconds

\n"; if(!Director::is_cli()) echo '
';