Skip to content

Implement benchmark diff commit fallback #18152

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

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 19 additions & 0 deletions benchmark/generate_diff.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ function main(?string $headCommitHash, ?string $baseCommitHash) {

$repo = __DIR__ . '/repos/data';
cloneRepo($repo, '[email protected]:php/benchmarking-data.git');
$baseCommitHash = find_benchmarked_commit_hash($baseCommitHash);
$headSummaryFile = $repo . '/' . substr($headCommitHash, 0, 2) . '/' . $headCommitHash . '/summary.json';
$baseSummaryFile = $repo . '/' . substr($baseCommitHash, 0, 2) . '/' . $baseCommitHash . '/summary.json';
if (!file_exists($headSummaryFile)) {
Expand Down Expand Up @@ -60,6 +61,24 @@ function formatDiff(?int $baseInstructions, int $headInstructions): string {
return sprintf('%.2f%%', $instructionDiff / $baseInstructions * 100);
}

function find_benchmarked_commit_hash(string $commitHash): ?string {
$repeat = 10;

while (true) {
if ($repeat-- <= 0) {
fwrite(STDERR, "Count not find benchmarked commit hash\n");
exit(1);
}
$summaryFile = __DIR__ . '/repos/data/' . substr($commitHash, 0, 2) . '/' . $commitHash . '/summary.json';
if (file_exists($summaryFile)) {
break;
}
$commitHash = trim(runCommand(['git', 'rev-parse', $commitHash . '^'], dirname(__DIR__))->stdout);
Copy link
Contributor

Choose a reason for hiding this comment

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

This must not print anything to the console - https://github.com/php/php-src/actions/runs/14118010354

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! I'll fix this later tonight.

}

return $commitHash;
}

$headCommitHash = $argv[1] ?? null;
$baseCommitHash = $argv[2] ?? null;
$output = main($headCommitHash, $baseCommitHash);
Expand Down
Loading