@@ -2,13 +2,44 @@ name: Real-time Benchmark
2
2
on :
3
3
schedule :
4
4
- 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 : ' Commit SHA that is going to be benchmarked (e.g. "123456789a")'
17
+ required : true
18
+ type : string
19
+ baseline_commit :
20
+ description : ' A commit SHA that is compared against the one provided by the "commit" input (e.g. "abcdef123456")'
21
+ required : true
22
+ type : string
23
+ jit :
24
+ description : ' Whether JIT is benchmarked'
25
+ required : false
26
+ type : choice
27
+ options :
28
+ - " 0"
29
+ - " 1"
5
30
permissions :
6
31
contents : read
7
32
jobs :
8
33
REAL_TIME_BENCHMARK :
9
34
name : REAL_TIME_BENCHMARK
10
- if : github.repository == 'php/php-src'
35
+ if : github.repository == 'php/php-src' || github.event_name == 'workflow_dispatch'
11
36
runs-on : ubuntu-22.04
37
+ env :
38
+ REPOSITORY : ${{ inputs.repository || 'php/php-src' }}
39
+ BRANCH : ${{ inputs.branch || 'master' }}
40
+ COMMIT : ${{ inputs.commit || github.sha }}
41
+ BASELINE_COMMIT : ${{ inputs.baseline_commit || 'd5f6e56610c729710073350af318c4ea1b292cfe' }}
42
+ JIT : ${{ inputs.jit || '1' }}
12
43
steps :
13
44
- name : Install dependencies
14
45
run : |
@@ -29,71 +60,143 @@ jobs:
29
60
ref : ' main'
30
61
fetch-depth : 1
31
62
path : ' php-version-benchmarks'
32
- - name : Checkout php-src
63
+ - name : Checkout php-src (benchmarked version)
33
64
uses : actions/checkout@v4
34
65
with :
35
- repository : ' php/php-src '
36
- ref : ' ${{ github.sha }}'
66
+ repository : ' ${{ env.REPOSITORY }} '
67
+ ref : ' ${{ env.COMMIT }}'
37
68
fetch-depth : 100
38
- path : ' php-version-benchmarks/tmp/php_master'
69
+ path : ' php-version-benchmarks/tmp/php_${{ env.BRANCH }}'
70
+ - name : Checkout php-src (baseline version)
71
+ uses : actions/checkout@v4
72
+ with :
73
+ repository : ' ${{ env.REPOSITORY }}'
74
+ ref : ' ${{ env.BASELINE_COMMIT }}'
75
+ fetch-depth : 100
76
+ path : ' php-version-benchmarks/tmp/php_baseline'
39
77
- name : Setup benchmark results
40
78
run : |
41
79
git config --global user.name "Benchmark"
42
80
git config --global user.email "[email protected] "
43
-
81
+
44
82
rm -rf ./php-version-benchmarks/docs/results
45
83
- name : Checkout benchmark data
84
+ if : github.repository == 'php/php-src' && github.event_name != 'workflow_dispatch'
46
85
uses : actions/checkout@v4
47
86
with :
48
87
repository : php/real-time-benchmark-data
49
88
ssh-key : ${{ secrets.PHP_VERSION_BENCHMARK_RESULTS_DEPLOY_KEY }}
50
89
path : ' php-version-benchmarks/docs/results'
51
- - name : Set benchmark config
90
+ - name : Setup infra config
52
91
run : |
53
92
set -e
54
93
55
- # Set infrastructure config
56
94
cp ./php-version-benchmarks/config/infra/aws/x86_64-metal.ini.dist ./php-version-benchmarks/config/infra/aws/x86_64-metal.ini
57
95
ESCAPED_DOCKER_REGISTRY=$(printf '%s\n' "${{ secrets.PHP_VERSION_BENCHMARK_DOCKER_REGISTRY }}" | sed -e 's/[\/&]/\\&/g')
58
96
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
59
97
cp ./php-version-benchmarks/build/infrastructure/config/aws.tfvars.dist ./php-version-benchmarks/build/infrastructure/config/aws.tfvars
60
98
sed -i 's/access_key = ""/access_key = "${{ secrets.PHP_VERSION_BENCHMARK_AWS_ACCESS_KEY }}"/g' ./php-version-benchmarks/build/infrastructure/config/aws.tfvars
61
99
sed -i 's/secret_key = ""/secret_key = "${{ secrets.PHP_VERSION_BENCHMARK_AWS_SECRET_KEY }}"/g' ./php-version-benchmarks/build/infrastructure/config/aws.tfvars
100
+ - name : Setup PHP config - baseline PHP version
101
+ if : github.repository == 'php/php-src' && github.event_name != 'workflow_dispatch'
102
+ run : |
103
+ set -e
104
+
105
+ BASELINE_SHORT_SHA="$(echo "${{ env.BASELINE_COMMIT }}" | cut -c1-4)"
106
+
107
+ cat << EOF > /php-version-benchmarks/config/php/baseline.ini
108
+ PHP_NAME="PHP - baseline@$BASELINE_SHORT_SHA"
109
+ PHP_ID=php_baseline
110
+
111
+ PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git
112
+ PHP_BRANCH=${{ env.BRANCH }}
113
+ PHP_COMMIT=${{ env.BASELINE_COMMIT }}
114
+
115
+ PHP_OPCACHE=1
116
+ PHP_JIT=0
117
+ EOF
118
+ - name : Setup PHP config - baseline PHP version with JIT (manual only)
119
+ if : github.repository == 'php/php-src' && github.event_name == 'workflow_dispatch' && inputs.jit == '1'
120
+ run : |
121
+ set -e
122
+
123
+ BASELINE_SHORT_SHA="$(echo "${{ env.BASELINE_COMMIT }}" | cut -c1-4)"
124
+
125
+ cat << EOF > /php-version-benchmarks/config/php/baseline.ini
126
+ PHP_NAME="PHP - baseline@$BASELINE_SHORT_SHA (JIT)"
127
+ PHP_ID=php_baseline_jit
128
+
129
+ PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git
130
+ PHP_BRANCH=${{ env.BRANCH }}
131
+ PHP_COMMIT=${{ env.BASELINE_COMMIT }}
132
+
133
+ PHP_OPCACHE=1
134
+ PHP_JIT=${{ env.JIT }}
135
+ EOF
136
+
137
+ git clone ./php-version-benchmarks/tmp/php_baseline/ ./php-version-benchmarks/tmp/php_baseline_jit
138
+ - name : Setup PHP config - previous PHP version (scheduled only)
139
+ if : github.repository == 'php/php-src' && github.event_name != 'workflow_dispatch'
140
+ run : |
141
+ set -e
62
142
63
143
YEAR="$(date '+%Y')"
64
144
DATABASE="./php-version-benchmarks/docs/results/$YEAR/database.tsv"
65
145
if [ -f "$DATABASE" ]; then
66
146
LAST_RESULT_SHA="$(tail -n 2 "$DATABASE" | head -n 1 | cut -f 6)"
67
147
else
68
148
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')"
149
+ LAST_RESULT_SHA="$(cd ./php-version-benchmarks/tmp/php_${{ env.BRANCH }} / && git --no-pager log --until="$YESTERDAY" -n 1 --pretty='%H')"
70
150
fi
71
151
72
- BASELINE_SHA="d5f6e56610c729710073350af318c4ea1b292cfe"
73
- BASELINE_SHORT_SHA="$(echo "$BASELINE_SHA" | cut -c1-4)"
152
+ cat << EOF > /php-version-benchmarks/config/php/previous.ini
153
+ PHP_NAME="PHP - previous ${{ env.BRANCH }}"
154
+ PHP_ID=php_${{ env.BRANCH }}_previous
155
+
156
+ PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git
157
+ PHP_BRANCH=${{ env.BRANCH }}
158
+ PHP_COMMIT=$LAST_RESULT_SHA
159
+
160
+ PHP_OPCACHE=1
161
+ PHP_JIT=0
162
+ EOF
163
+ - name : Setup PHP config - benchmarked PHP version
164
+ run : |
165
+ set -e
166
+
167
+ cat << EOF > /php-version-benchmarks/config/php/this.ini
168
+ PHP_NAME="PHP - ${{ env.BRANCH }}"
169
+ PHP_ID=php_${{ env.BRANCH }}
74
170
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
171
+ PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git
172
+ PHP_BRANCH=${{ env.BRANCH }}
173
+ PHP_COMMIT=${{ env.COMMIT }}
80
174
81
- # Set config for the previous PHP version
82
- cp ./php-version-benchmarks/config/php/master.ini.dist ./php-version-benchmarks/config/php/master_last.ini
83
- sed -i 's/PHP_NAME="PHP - master"/PHP_NAME="PHP - previous master"/g' ./php-version-benchmarks/config/php/master_last.ini
84
- sed -i "s/PHP_ID=php_master/PHP_ID=php_master_previous/g" ./php-version-benchmarks/config/php/master_last.ini
85
- sed -i "s/PHP_COMMIT=/PHP_COMMIT=$LAST_RESULT_SHA/g" ./php-version-benchmarks/config/php/master_last.ini
175
+ PHP_OPCACHE=1
176
+ PHP_JIT=0
177
+ EOF
178
+ - name : Setup PHP config - benchmarked PHP version with JIT
179
+ if : env.JIT == '1'
180
+ run : |
181
+ set -e
182
+
183
+ cat << EOF > /php-version-benchmarks/config/php/this_jit.ini
184
+ PHP_NAME="PHP - ${{ env.BRANCH }} (JIT)"
185
+ PHP_ID=php_${{ env.BRANCH }}_jit
186
+
187
+ PHP_REPO=https://github.com/${{ env.REPOSITORY }}.git
188
+ PHP_BRANCH=${{ env.BRANCH }}
189
+ PHP_COMMIT=${{ env.COMMIT }}
86
190
87
- # Set config for the current PHP version
88
- cp ./php-version-benchmarks/config/php/master.ini.dist ./php-version-benchmarks/config/php/master_now.ini
89
- sed -i "s/PHP_COMMIT=/PHP_COMMIT=${{ github.sha }}/g" ./php-version-benchmarks/config/php/master_now.ini
191
+ PHP_OPCACHE=1
192
+ PHP_JIT=${{ env.JIT }}
193
+ EOF
90
194
91
- # Set config for current PHP version with JIT
92
- git clone ./php-version-benchmarks/tmp/php_master/ ./php-version-benchmarks/tmp/php_master_jit
93
- cp ./php-version-benchmarks/config/php/master_jit.ini.dist ./php-version-benchmarks/config/php/master_now_jit.ini
94
- sed -i "s/PHP_COMMIT=/PHP_COMMIT=${{ github.sha }}/g" ./php-version-benchmarks/config/php/master_now_jit.ini
195
+ git clone ./php-version-benchmarks/tmp/php_${{ env.BRANCH }}/ ./php- version-benchmarks/tmp/php_${{ env.BRANCH }}_jit
196
+ - name : Setup test config
197
+ run : |
198
+ set -e
95
199
96
- # Set test configs
97
200
cp ./php-version-benchmarks/config/test/1_laravel.ini.dist ./php-version-benchmarks/config/test/1_laravel.ini
98
201
cp ./php-version-benchmarks/config/test/2_symfony_main.ini.dist ./php-version-benchmarks/config/test/2_symfony_main.ini
99
202
cp ./php-version-benchmarks/config/test/4_wordpress.ini.dist ./php-version-benchmarks/config/test/4_wordpress.ini
@@ -102,6 +205,7 @@ jobs:
102
205
- name : Run benchmark
103
206
run : ./php-version-benchmarks/benchmark.sh run aws
104
207
- name : Store results
208
+ if : github.repository == 'php/php-src' && github.event_name != 'workflow_dispatch'
105
209
run : |
106
210
set -ex
107
211
@@ -117,6 +221,17 @@ jobs:
117
221
fi
118
222
git commit -m "Add result for ${{ github.repository }}@${{ github.sha }}"
119
223
git push
224
+ - name : Comment results
225
+ if : github.repository != 'php/php-src' && github.event_name == 'workflow_dispatch'
226
+ env :
227
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
228
+ run : |
229
+ PR_NUMBER=$(gh pr list --head "${{ inputs.branch }}" --state open --json number --jq '.[0].number')
230
+ if [ ! -z "$PR_NUMBER" ]; then
231
+ YEAR="$(date '+%Y')"
232
+ NEWEST_RESULT_DIRECTORY=$(ls -td ./php-version-benchmarks/docs/results/$YEAR/*/ | head -1)
233
+ gh pr comment $PR_NUMBER --body-file "$NEWEST_RESULT_DIRECTORY/result.md"
234
+ fi
120
235
- name : Cleanup
121
236
if : always()
122
237
run : |
0 commit comments