@@ -2,13 +2,71 @@ name: Real-time Benchmark
22on :
33  schedule :
44    - cron : " 30 0 * * *" 
5+   workflow_dispatch :
6+     inputs :
7+       repository :
8+         description : ' Repository name that is going to be benchmarked (e.g. "johndoe/php-src")' 
9+         required : true 
10+         type : string 
11+       branch :
12+         description : ' Branch name that is going to be benchmarked (e.g. "my-branch")' 
13+         required : true 
14+         type : string 
15+       commit :
16+         description : ' Full commit SHA that is going to be benchmarked (e.g. "123456789a...")' 
17+         required : true 
18+         type : string 
19+       baseline_commit :
20+         description : ' Full commit SHA that is compared against the one provided by the "commit" input (e.g. "abcdef123456...")' 
21+         required : true 
22+         type : string 
23+       id :
24+         description : ' ID of the benchmarked code. It should be a valid identifier (e.g. "master", "php_85").' 
25+         required : false 
26+         default : " benchmarked" 
27+         type : string 
28+       opcache :
29+         description : ' Whether opcache should be enabled for the benchmarked code' 
30+         required : true 
31+         default : " 1" 
32+         type : choice 
33+         options :
34+           - " 0" 
35+           - " 1" 
36+           - " 2" 
37+       baseline_opcache :
38+         description : ' Whether opcache should be enabled for the baseline' 
39+         required : true 
40+         default : " 1" 
41+         type : choice 
42+         options :
43+           - " 0" 
44+           - " 1" 
45+           - " 2" 
46+       jit :
47+         description : ' Whether JIT is benchmarked' 
48+         required : false 
49+         type : choice 
50+         options :
51+           - " 0" 
52+           - " 1" 
553permissions :
654  contents : read 
755jobs :
856  REAL_TIME_BENCHMARK :
957    name : REAL_TIME_BENCHMARK 
10-     if : github.repository == 'php /php-src' 
58+     if : github.repository == 'kocsismate /php-src' || github.event_name == 'workflow_dispatch ' 
1159    runs-on : ubuntu-22.04 
60+     env :
61+       REPOSITORY : ${{ inputs.repository || 'php/php-src' }} 
62+       BRANCH : ${{ inputs.branch || 'master' }} 
63+       COMMIT : ${{ inputs.commit || github.sha }} 
64+       BASELINE_COMMIT : ${{ inputs.baseline_commit || 'd5f6e56610c729710073350af318c4ea1b292cfe' }} 
65+       ID : ${{ inputs.id || 'master' }} 
66+       OPCACHE : ${{ inputs.opcache || '1' }} 
67+       BASELINE_OPCACHE : ${{ inputs.baseline_opcache || '2' }} 
68+       JIT : ${{ inputs.jit || '1' }} 
69+       YEAR : " " 
1270    steps :
1371      - name : Install dependencies 
1472        run : | 
@@ -29,81 +87,155 @@ jobs:
2987          ref : ' main' 
3088          fetch-depth : 1 
3189          path : ' php-version-benchmarks' 
32-       - name : Checkout php-src 
90+       - name : Checkout php-src (benchmarked version)  
3391        uses : actions/checkout@v4 
3492        with :
35-           repository : ' php/php-src ' 
36-           ref : ' ${{ github.sha  }}' 
93+           repository : ' ${{ env.REPOSITORY }} ' 
94+           ref : ' ${{ env.COMMIT  }}' 
3795          fetch-depth : 100 
38-           path : ' php-version-benchmarks/tmp/php_master' 
39-       - name : Setup benchmark results 
96+           path : ' php-version-benchmarks/tmp/php_${{ env.ID }}' 
97+       - name : Checkout php-src (baseline version) 
98+         uses : actions/checkout@v4 
99+         with :
100+           repository : ' ${{ env.REPOSITORY }}' 
101+           ref : ' ${{ env.BASELINE_COMMIT }}' 
102+           fetch-depth : 100 
103+           path : ' php-version-benchmarks/tmp/php_baseline' 
104+       - name : Setup benchmark and results 
40105        run : | 
41106          git config --global user.name "Benchmark" 
42107          git config --global user.email "[email protected] " 43108           
109+           YEAR="$(date '+%Y')" 
110+           echo "YEAR=$YEAR" >> $GITHUB_ENV 
111+ 
44112          rm -rf ./php-version-benchmarks/docs/results 
45113       - name : Checkout benchmark data 
114+         if : github.repository == 'kocsismate/php-src' && github.event_name != 'workflow_dispatch' 
46115        uses : actions/checkout@v4 
47116        with :
48117          repository : php/real-time-benchmark-data 
49118          ssh-key : ${{ secrets.PHP_VERSION_BENCHMARK_RESULTS_DEPLOY_KEY }} 
50119          path : ' php-version-benchmarks/docs/results' 
51-       - name : Set benchmark  config
120+       - name : Setup infra  config
52121        run : | 
53122          set -e 
54123
55-           # Set infrastructure config 
56124          cp ./php-version-benchmarks/config/infra/aws/x86_64-metal.ini.dist ./php-version-benchmarks/config/infra/aws/x86_64-metal.ini 
57125          ESCAPED_DOCKER_REGISTRY=$(printf '%s\n' "${{ secrets.PHP_VERSION_BENCHMARK_DOCKER_REGISTRY }}" | sed -e 's/[\/&]/\\&/g') 
58126          sed -i "s/INFRA_DOCKER_REGISTRY=public.ecr.aws\/abcdefgh/INFRA_DOCKER_REGISTRY=$ESCAPED_DOCKER_REGISTRY/g" ./php-version-benchmarks/config/infra/aws/x86_64-metal.ini 
59127          cp ./php-version-benchmarks/build/infrastructure/config/aws.tfvars.dist ./php-version-benchmarks/build/infrastructure/config/aws.tfvars 
60128          sed -i 's/access_key = ""/access_key = "${{ secrets.PHP_VERSION_BENCHMARK_AWS_ACCESS_KEY }}"/g' ./php-version-benchmarks/build/infrastructure/config/aws.tfvars 
61129          sed -i 's/secret_key = ""/secret_key = "${{ secrets.PHP_VERSION_BENCHMARK_AWS_SECRET_KEY }}"/g' ./php-version-benchmarks/build/infrastructure/config/aws.tfvars 
130+           sed -i 's/github_token = ""/github_token = "${{ secrets.PHP_VERSION_BENCHMARK_GITHUB_TOKEN }}"/g' ./php-version-benchmarks/build/infrastructure/config/aws.tfvars 
131+        - name : Setup PHP config - baseline PHP version 
132+         if : github.repository == 'kocsismate/php-src' && github.event_name != 'workflow_dispatch' 
133+         run : | 
134+           set -e 
62135
63-           YEAR="$(date '+%Y')" 
64-           DATABASE="./php-version-benchmarks/docs/results/$YEAR/database.tsv" 
136+           BASELINE_SHORT_SHA="$(echo "${{ env.BASELINE_COMMIT }}" | cut -c1-4)" 
137+ 
138+           cat << EOF > ./php-version-benchmarks/config/php/baseline.ini 
139+             PHP_NAME="PHP - baseline@$BASELINE_SHORT_SHA" 
140+             PHP_ID=php_baseline 
141+ 
142+             PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git 
143+             PHP_BRANCH=${{ env.BRANCH }} 
144+             PHP_COMMIT=${{ env.BASELINE_COMMIT }} 
145+ 
146+             PHP_OPCACHE=${{ env.BASELINE_OPCACHE }} 
147+             PHP_JIT=0 
148+           EOF 
149+        - name : Setup PHP config - baseline PHP version with JIT (manual only) 
150+         if : github.repository == 'kocsismate/php-src' && github.event_name == 'workflow_dispatch' && inputs.jit == '1' 
151+         run : | 
152+           set -e 
153+ 
154+           BASELINE_SHORT_SHA="$(echo "${{ env.BASELINE_COMMIT }}" | cut -c1-4)" 
155+            
156+           cat << EOF > ./php-version-benchmarks/config/php/baseline.ini 
157+             PHP_NAME="PHP - baseline@$BASELINE_SHORT_SHA (JIT)" 
158+             PHP_ID=php_baseline_jit 
159+ 
160+             PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git 
161+             PHP_BRANCH=${{ env.BRANCH }} 
162+             PHP_COMMIT=${{ env.BASELINE_COMMIT }} 
163+ 
164+             PHP_OPCACHE=${{ env.BASELINE_OPCACHE }} 
165+             PHP_JIT=${{ env.JIT }} 
166+           EOF 
167+ 
168+           git clone ./php-version-benchmarks/tmp/php_baseline/ ./php-version-benchmarks/tmp/php_baseline_jit 
169+        - name : Setup PHP config - previous PHP version (scheduled only) 
170+         if : github.repository == 'kocsismate/php-src' && github.event_name != 'workflow_dispatch' 
171+         run : | 
172+           set -e 
173+ 
174+           DATABASE="./php-version-benchmarks/docs/results/${{ env.YEAR }}/database.tsv" 
65175          if [ -f "$DATABASE" ]; then 
66176            LAST_RESULT_SHA="$(tail -n 2 "$DATABASE" | head -n 1 | cut -f 6)" 
67177          else 
68178            YESTERDAY="$(date -d "-2 day 23:59:59" '+%Y-%m-%d %H:%M:%S')" 
69-             LAST_RESULT_SHA="$(cd ./php-version-benchmarks/tmp/php_master / && git --no-pager log --until="$YESTERDAY" -n 1 --pretty='%H')" 
179+             LAST_RESULT_SHA="$(cd ./php-version-benchmarks/tmp/php_${{ env.ID }} / && git --no-pager log --until="$YESTERDAY" -n 1 --pretty='%H')" 
70180          fi 
71181
72-           BASELINE_SHA="d5f6e56610c729710073350af318c4ea1b292cfe" 
73-           BASELINE_SHORT_SHA="$(echo "$BASELINE_SHA" | cut -c1-4)" 
74- 
75-           # Set config for the baseline PHP version 
76-           cp ./php-version-benchmarks/config/php/master.ini.dist ./php-version-benchmarks/config/php/master_baseline.ini 
77-           sed -i 's/PHP_NAME="PHP - master"/PHP_NAME="PHP - baseline@'"$BASELINE_SHORT_SHA"'"/g' ./php-version-benchmarks/config/php/master_baseline.ini 
78-           sed -i "s/PHP_ID=php_master/PHP_ID=php_master_baseline/g" ./php-version-benchmarks/config/php/master_baseline.ini 
79-           sed -i "s/PHP_COMMIT=/PHP_COMMIT=$BASELINE_SHA/g" ./php-version-benchmarks/config/php/master_baseline.ini 
80-           sed -i "s/PHP_OPCACHE=1/PHP_OPCACHE=2/g" ./php-version-benchmarks/config/php/master_baseline.ini 
81- 
82-           # Set config for the previous PHP version 
83-           cp ./php-version-benchmarks/config/php/master.ini.dist ./php-version-benchmarks/config/php/master_last.ini 
84-           sed -i 's/PHP_NAME="PHP - master"/PHP_NAME="PHP - previous master"/g' ./php-version-benchmarks/config/php/master_last.ini 
85-           sed -i "s/PHP_ID=php_master/PHP_ID=php_master_previous/g" ./php-version-benchmarks/config/php/master_last.ini 
86-           sed -i "s/PHP_COMMIT=/PHP_COMMIT=$LAST_RESULT_SHA/g" ./php-version-benchmarks/config/php/master_last.ini 
87-           sed -i "s/PHP_OPCACHE=1/PHP_OPCACHE=2/g" ./php-version-benchmarks/config/php/master_last.ini 
88- 
89-           # Set config for the current PHP version 
90-           cp ./php-version-benchmarks/config/php/master.ini.dist ./php-version-benchmarks/config/php/master_now.ini 
91-           sed -i "s/PHP_COMMIT=/PHP_COMMIT=${{ github.sha }}/g" ./php-version-benchmarks/config/php/master_now.ini 
92- 
93-           # Set config for current PHP version with JIT 
94-           git clone ./php-version-benchmarks/tmp/php_master/ ./php-version-benchmarks/tmp/php_master_jit 
95-           cp ./php-version-benchmarks/config/php/master_jit.ini.dist ./php-version-benchmarks/config/php/master_now_jit.ini 
96-           sed -i "s/PHP_COMMIT=/PHP_COMMIT=${{ github.sha }}/g" ./php-version-benchmarks/config/php/master_now_jit.ini 
97- 
98-           # Set test configs 
182+           cat << EOF > ./php-version-benchmarks/config/php/previous.ini 
183+             PHP_NAME="PHP - previous ${{ env.BRANCH }}" 
184+             PHP_ID=php_previous 
185+ 
186+             PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git 
187+             PHP_BRANCH=${{ env.BRANCH }} 
188+             PHP_COMMIT=$LAST_RESULT_SHA 
189+ 
190+             PHP_OPCACHE=1 
191+             PHP_JIT=0 
192+           EOF 
193+        - name : Setup PHP config - benchmarked PHP version 
194+         run : | 
195+           set -e 
196+ 
197+           cat << EOF > ./php-version-benchmarks/config/php/this.ini 
198+             PHP_NAME="PHP - ${{ env.BRANCH }}" 
199+             PHP_ID=php_${{ env.ID }} 
200+ 
201+             PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git 
202+             PHP_BRANCH=${{ env.BRANCH }} 
203+             PHP_COMMIT=${{ env.COMMIT }} 
204+ 
205+             PHP_OPCACHE=${{ env.OPCACHE }} 
206+             PHP_JIT=0 
207+           EOF 
208+        - name : Setup PHP config - benchmarked PHP version with JIT 
209+         if : env.JIT == '1' 
210+         run : | 
211+           set -e 
212+ 
213+           cat << EOF > ./php-version-benchmarks/config/php/this_jit.ini 
214+             PHP_NAME="PHP - ${{ env.BRANCH }} (JIT)" 
215+             PHP_ID=php_${{ env.ID }}_jit 
216+ 
217+             PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git 
218+             PHP_BRANCH=${{ env.BRANCH }} 
219+             PHP_COMMIT=${{ env.COMMIT }} 
220+ 
221+             PHP_OPCACHE=${{ env.OPCACHE }} 
222+             PHP_JIT=${{ env.JIT }} 
223+           EOF 
224+ 
225+           git clone ./php-version-benchmarks/tmp/php_${{ env.ID }}/ ./php-version-benchmarks/tmp/php_${{ env.ID }}_jit 
226+        - name : Setup test config 
227+         run : | 
228+           set -e 
229+ 
99230          cp ./php-version-benchmarks/config/test/1_laravel.ini.dist ./php-version-benchmarks/config/test/1_laravel.ini 
100231          cp ./php-version-benchmarks/config/test/2_symfony_main.ini.dist ./php-version-benchmarks/config/test/2_symfony_main.ini 
101232          cp ./php-version-benchmarks/config/test/4_wordpress.ini.dist ./php-version-benchmarks/config/test/4_wordpress.ini 
102233          cp ./php-version-benchmarks/config/test/5_bench.php.ini.dist ./php-version-benchmarks/config/test/5_bench.php.ini 
103234          cp ./php-version-benchmarks/config/test/6_micro_bench.php.ini.dist ./php-version-benchmarks/config/test/6_micro_bench.php.ini 
104235       - name : Run benchmark 
105236        run : ./php-version-benchmarks/benchmark.sh run aws 
106-       - name : Store results 
237+       - name : Store results (scheduled only) 
238+         if : github.repository == 'kocsismate/php-src' && github.event_name != 'workflow_dispatch' 
107239        run : | 
108240          set -ex 
109241
@@ -119,6 +251,24 @@ jobs:
119251          fi 
120252          git commit -m "Add result for ${{ github.repository }}@${{ github.sha }}" 
121253          git push 
254+        - name : Upload artifact (manual only) 
255+         if : github.event_name == 'workflow_dispatch' 
256+         uses : actions/upload-artifact@v4 
257+         with :
258+           name : results 
259+           path : ./php-version-benchmarks/docs/results/${{ env.YEAR }} 
260+           retention-days : 30 
261+       - name : Comment results 
262+         if : github.repository != 'php/php-src' && github.event_name == 'workflow_dispatch' 
263+         env :
264+           GH_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
265+         run : | 
266+           cd ./php-version-benchmarks/tmp/php_${{ env.ID }} 
267+           PR_NUMBER=$(gh pr list --head "${{ inputs.branch }}" --state open --json number --jq '.[0].number') 
268+           if [ ! -z "$PR_NUMBER" ]; then 
269+             NEWEST_RESULT_DIRECTORY=$(ls -td ./php-version-benchmarks/docs/results/${{ env.YEAR }}/*/ | head -1) 
270+             gh pr comment $PR_NUMBER --body-file "$NEWEST_RESULT_DIRECTORY/result.md" 
271+           fi 
122272       - name : Cleanup 
123273        if : always() 
124274        run : | 
0 commit comments