Add miliseconds do the test time output (#12729)

Also replaced microtime() with hrtime()
This commit is contained in:
Jorg Adam Sowa 2023-12-29 17:03:30 +01:00 committed by GitHub
parent 703ef91edb
commit 948b2bc211
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -682,13 +682,14 @@ function main(): void
if ($test_cnt) {
putenv('NO_INTERACTION=1');
usort($test_files, "test_sort");
$start_time = time();
$start_timestamp = time();
$start_time = hrtime(true);
echo "Running selected tests.\n";
$test_idx = 0;
run_all_tests($test_files, $environment);
$end_time = time();
$end_time = hrtime(true);
if ($failed_tests_file) {
fclose($failed_tests_file);
@ -730,13 +731,14 @@ function main(): void
$test_files = array_unique($test_files);
usort($test_files, "test_sort");
$start_time = time();
$start_timestamp = time();
$start_time = hrtime(true);
show_start($start_time);
$test_cnt = count($test_files);
$test_idx = 0;
run_all_tests($test_files, $environment);
$end_time = time();
$end_time = hrtime(true);
if ($failed_tests_file) {
fclose($failed_tests_file);
@ -755,7 +757,7 @@ function main(): void
compute_summary();
show_end($end_time);
show_end($start_timestamp, $start_time, $end_time);
show_summary();
save_results($output_file, /* prompt_to_save_results: */ true);
@ -3064,7 +3066,7 @@ Expected leak : ' . sprintf('%5d (%5.1f%%)', $sum_results['XLEAKED'], $percent
$summary .= '
Tests passed : ' . sprintf('%5d (%5.1f%%)', $sum_results['PASSED'], $percent_results['PASSED']) . ' ' . sprintf('(%5.1f%%)', $x_passed) . '
---------------------------------------------------------------------
Time taken : ' . sprintf('%5d seconds', $end_time - $start_time) . '
Time taken : ' . sprintf('%5.3f seconds', ($end_time - $start_time) / 1e9) . '
=====================================================================
';
$failed_test_summary = '';
@ -3167,14 +3169,14 @@ EXPECTED LEAK TEST SUMMARY
return $summary;
}
function show_start(int $start_time): void
function show_start(int $start_timestamp): void
{
echo "TIME START " . date('Y-m-d H:i:s', $start_time) . "\n=====================================================================\n";
echo "TIME START " . date('Y-m-d H:i:s', $start_timestamp) . "\n=====================================================================\n";
}
function show_end(int $end_time): void
function show_end(int $start_timestamp, int|float $start_time, int|float $end_time): void
{
echo "=====================================================================\nTIME END " . date('Y-m-d H:i:s', $end_time) . "\n";
echo "=====================================================================\nTIME END " . date('Y-m-d H:i:s', $start_timestamp + (int)(($end_time - $start_time)/1e9)) . "\n";
}
function show_summary(): void