@@ -10,6 +10,7 @@ function main(?string $headCommitHash, ?string $baseCommitHash) {
1010
1111 $ repo = __DIR__ . '/repos/data ' ;
1212 cloneRepo (
$ repo,
'[email protected] :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