mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Merge branch 'PHP-8.4'
* PHP-8.4: Implement benchmark diff commit fallback
This commit is contained in:
commit
ab6e464ae2
1 changed files with 19 additions and 0 deletions
|
@ -10,6 +10,7 @@ function main(?string $headCommitHash, ?string $baseCommitHash) {
|
||||||
|
|
||||||
$repo = __DIR__ . '/repos/data';
|
$repo = __DIR__ . '/repos/data';
|
||||||
cloneRepo($repo, 'git@github.com:php/benchmarking-data.git');
|
cloneRepo($repo, 'git@github.com:php/benchmarking-data.git');
|
||||||
|
$baseCommitHash = find_benchmarked_commit_hash($repo, $baseCommitHash);
|
||||||
$headSummaryFile = $repo . '/' . substr($headCommitHash, 0, 2) . '/' . $headCommitHash . '/summary.json';
|
$headSummaryFile = $repo . '/' . substr($headCommitHash, 0, 2) . '/' . $headCommitHash . '/summary.json';
|
||||||
$baseSummaryFile = $repo . '/' . substr($baseCommitHash, 0, 2) . '/' . $baseCommitHash . '/summary.json';
|
$baseSummaryFile = $repo . '/' . substr($baseCommitHash, 0, 2) . '/' . $baseCommitHash . '/summary.json';
|
||||||
if (!file_exists($headSummaryFile)) {
|
if (!file_exists($headSummaryFile)) {
|
||||||
|
@ -60,6 +61,24 @@ function formatDiff(?int $baseInstructions, int $headInstructions): string {
|
||||||
return sprintf('%.2f%%', $instructionDiff / $baseInstructions * 100);
|
return sprintf('%.2f%%', $instructionDiff / $baseInstructions * 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function find_benchmarked_commit_hash(string $repo, string $commitHash): ?string {
|
||||||
|
$repeat = 10;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if ($repeat-- <= 0) {
|
||||||
|
fwrite(STDERR, "Count not find benchmarked commit hash\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
$summaryFile = $repo . '/' . substr($commitHash, 0, 2) . '/' . $commitHash . '/summary.json';
|
||||||
|
if (file_exists($summaryFile)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$commitHash = trim(runCommand(['git', 'rev-parse', $commitHash . '^'], dirname(__DIR__))->stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $commitHash;
|
||||||
|
}
|
||||||
|
|
||||||
$headCommitHash = $argv[1] ?? null;
|
$headCommitHash = $argv[1] ?? null;
|
||||||
$baseCommitHash = $argv[2] ?? null;
|
$baseCommitHash = $argv[2] ?? null;
|
||||||
$output = main($headCommitHash, $baseCommitHash);
|
$output = main($headCommitHash, $baseCommitHash);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue