diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index f9076f4..d136e7b 100755 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -72,9 +72,15 @@ simpletest_script_reporter_init(); // Execute tests. +$bench = array(); for ($i = 0; $i < $args['repeat']; $i++) { simpletest_script_execute_batch($test_list); } +echo "\n", 'Most expensive tests:', "\n\n"; +arsort($bench); +foreach ($bench as $class => $time) { + echo sprintf('%8.3fs %s', $time, $class), "\n"; +} // Stop the timer. simpletest_script_reporter_timer_stop(); @@ -615,6 +621,7 @@ function simpletest_script_execute_batch($test_classes) { 'test_id' => $test_id, 'class' => $test_class, 'pipes' => $pipes, + 'start' => microtime(TRUE), ); } @@ -625,9 +632,14 @@ function simpletest_script_execute_batch($test_classes) { foreach ($children as $cid => $child) { $status = proc_get_status($child['process']); if (empty($status['running'])) { + // Record total time of test class. + $GLOBALS['bench'][$child['class']] = microtime(TRUE) - $child['start']; + + // Print stdout of the subprocess (TestBase::bench() output). echo 'Bench: ', $child['class'], "\n"; echo stream_get_contents($child['pipes'][1]); fclose($child['pipes'][1]); + // The child exited, unregister it. proc_close($child['process']); if ($status['exitcode']) {