Skip to content

Add miliseconds do the test time output #12729

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions run-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -3064,7 +3066,7 @@ function get_summary(bool $show_ext_summary): string
$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 = '';
Expand Down Expand Up @@ -3167,14 +3169,14 @@ function get_summary(bool $show_ext_summary): string
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";
Copy link
Member

@iluuu1994 iluuu1994 Jan 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look correct. $start_timestamp is rounded down. The end time can still be $start_timestamp + 1, even if ($end_time - $start_time) < 1. I don't understand why this was changed at all.

}

function show_summary(): void
Expand Down