Skip to content

Commit 948b2bc

Browse files
authored
Add miliseconds do the test time output (#12729)
Also replaced microtime() with hrtime()
1 parent 703ef91 commit 948b2bc

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

run-tests.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -682,13 +682,14 @@ function main(): void
682682
if ($test_cnt) {
683683
putenv('NO_INTERACTION=1');
684684
usort($test_files, "test_sort");
685-
$start_time = time();
685+
$start_timestamp = time();
686+
$start_time = hrtime(true);
686687

687688
echo "Running selected tests.\n";
688689

689690
$test_idx = 0;
690691
run_all_tests($test_files, $environment);
691-
$end_time = time();
692+
$end_time = hrtime(true);
692693

693694
if ($failed_tests_file) {
694695
fclose($failed_tests_file);
@@ -730,13 +731,14 @@ function main(): void
730731
$test_files = array_unique($test_files);
731732
usort($test_files, "test_sort");
732733

733-
$start_time = time();
734+
$start_timestamp = time();
735+
$start_time = hrtime(true);
734736
show_start($start_time);
735737

736738
$test_cnt = count($test_files);
737739
$test_idx = 0;
738740
run_all_tests($test_files, $environment);
739-
$end_time = time();
741+
$end_time = hrtime(true);
740742

741743
if ($failed_tests_file) {
742744
fclose($failed_tests_file);
@@ -755,7 +757,7 @@ function main(): void
755757

756758
compute_summary();
757759

758-
show_end($end_time);
760+
show_end($start_timestamp, $start_time, $end_time);
759761
show_summary();
760762

761763
save_results($output_file, /* prompt_to_save_results: */ true);
@@ -3064,7 +3066,7 @@ function get_summary(bool $show_ext_summary): string
30643066
$summary .= '
30653067
Tests passed : ' . sprintf('%5d (%5.1f%%)', $sum_results['PASSED'], $percent_results['PASSED']) . ' ' . sprintf('(%5.1f%%)', $x_passed) . '
30663068
---------------------------------------------------------------------
3067-
Time taken : ' . sprintf('%5d seconds', $end_time - $start_time) . '
3069+
Time taken : ' . sprintf('%5.3f seconds', ($end_time - $start_time) / 1e9) . '
30683070
=====================================================================
30693071
';
30703072
$failed_test_summary = '';
@@ -3167,14 +3169,14 @@ function get_summary(bool $show_ext_summary): string
31673169
return $summary;
31683170
}
31693171

3170-
function show_start(int $start_time): void
3172+
function show_start(int $start_timestamp): void
31713173
{
3172-
echo "TIME START " . date('Y-m-d H:i:s', $start_time) . "\n=====================================================================\n";
3174+
echo "TIME START " . date('Y-m-d H:i:s', $start_timestamp) . "\n=====================================================================\n";
31733175
}
31743176

3175-
function show_end(int $end_time): void
3177+
function show_end(int $start_timestamp, int|float $start_time, int|float $end_time): void
31763178
{
3177-
echo "=====================================================================\nTIME END " . date('Y-m-d H:i:s', $end_time) . "\n";
3179+
echo "=====================================================================\nTIME END " . date('Y-m-d H:i:s', $start_timestamp + (int)(($end_time - $start_time)/1e9)) . "\n";
31783180
}
31793181

31803182
function show_summary(): void

0 commit comments

Comments
 (0)