Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ab6e464

Browse files
Merge branch 'PHP-8.4'
* PHP-8.4: Implement benchmark diff commit fallback
2 parents 36ae82b + 5ea386d commit ab6e464

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎benchmark/generate_diff.php‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function main(?string $headCommitHash, ?string $baseCommitHash) {
1010

1111
$repo = __DIR__ . '/repos/data';
1212
cloneRepo($repo, 'git@github.com:php/benchmarking-data.git');
13+
$baseCommitHash = find_benchmarked_commit_hash($repo, $baseCommitHash);
1314
$headSummaryFile = $repo . '/' . substr($headCommitHash, 0, 2) . '/' . $headCommitHash . '/summary.json';
1415
$baseSummaryFile = $repo . '/' . substr($baseCommitHash, 0, 2) . '/' . $baseCommitHash . '/summary.json';
1516
if (!file_exists($headSummaryFile)) {
@@ -60,6 +61,24 @@ function formatDiff(?int $baseInstructions, int $headInstructions): string {
6061
return sprintf('%.2f%%', $instructionDiff / $baseInstructions * 100);
6162
}
6263

64+
function find_benchmarked_commit_hash(string $repo, string $commitHash): ?string {
65+
$repeat = 10;
66+
67+
while (true) {
68+
if ($repeat-- <= 0) {
69+
fwrite(STDERR, "Count not find benchmarked commit hash\n");
70+
exit(1);
71+
}
72+
$summaryFile = $repo . '/' . substr($commitHash, 0, 2) . '/' . $commitHash . '/summary.json';
73+
if (file_exists($summaryFile)) {
74+
break;
75+
}
76+
$commitHash = trim(runCommand(['git', 'rev-parse', $commitHash . '^'], dirname(__DIR__))->stdout);
77+
}
78+
79+
return $commitHash;
80+
}
81+
6382
$headCommitHash = $argv[1] ?? null;
6483
$baseCommitHash = $argv[2] ?? null;
6584
$output = main($headCommitHash, $baseCommitHash);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /