@@ -235,10 +235,92 @@ jobs:
235235 name : redis-results
236236 path : redis-benchmark.md
237237
238+ postgres-bench :
239+ runs-on : ubuntu-latest
240+ if : (github.event_name == 'workflow_dispatch' || (github.event.issue.pull_request && contains(github.event.comment.body, '!bench'))) && !contains(github.event.comment.body, '!skippostgres')
241+ outputs :
242+ pr-sha : ${{ steps.sha.outputs.result || github.sha }}
243+ steps :
244+ - name : Install Hyperfine
245+ run : |
246+ wget https://github.com/sharkdp/hyperfine/releases/download/v1.11.0/hyperfine_1.11.0_amd64.deb
247+ sudo dpkg -i hyperfine_1.11.0_amd64.deb
248+
249+ - name : Get PR SHA
250+ if : github.event_name == 'issue_comment'
251+ id : sha
252+ uses : actions/github-script@v6
253+ with :
254+ result-encoding : string
255+ script : |
256+ const response = await github.request(context.payload.issue.pull_request.url);
257+ return response.data.head.sha;
258+
259+ - name : Checkout PR
260+ uses : actions/checkout@v4
261+ with :
262+ ref : ${{ steps.sha.outputs.result || github.sha }}
263+
264+ - name : Set up Go
265+ uses : actions/setup-go@v5
266+ with :
267+ go-version : 1.24
268+ check-latest : true
269+ cache : true
270+
271+ - name : Build PR
272+ run : |
273+ go build -o bench-pr ./bench
274+
275+ - name : Checkout main branch
276+ uses : actions/checkout@v4
277+ with :
278+ clean : false
279+ ref : main
280+
281+ - name : Build main
282+ run : |
283+ go build -o bench-main ./bench
284+
285+ - name : Start Postgres
286+ uses : ikalnytskyi/action-setup-postgres@v7
287+ with :
288+ username : root
289+ password : root
290+ database : postgres
291+ port : 5432
292+ postgres-version : " 16"
293+
294+ - name : Run Postgres benchmarks
295+ run : |
296+ echo "## Postgres run" > postgres-benchmark.md
297+ hyperfine --show-output --warmup 1 --export-markdown bench-postgres.md -n 'postgres-main' './bench-main -runs 2 -backend postgres' -n 'postgres-pr' './bench-pr -runs 2 -backend postgres'
298+ cat bench-postgres.md >> postgres-benchmark.md
299+
300+ - name : Run large Postgres benchmarks
301+ if : contains(github.event.comment.body, '!large')
302+ run : |
303+ echo "## Large Postgres payload run (1MB)" >> postgres-benchmark.md
304+ hyperfine --show-output --warmup 1 --export-markdown bench-postgres-l.md -n 'postgres-main' './bench-main -resultsize 1000000 -activities 10 -runs 2 -backend postgres -timeout 240s' -n 'postgres-pr' './bench-pr -resultsize 1000000 -activities 10 -runs 2 -backend postgres -timeout 240s'
305+ cat bench-postgres-l.md >> postgres-benchmark.md
306+
307+ - name : Run very large Postgres benchmarks
308+ if : contains(github.event.comment.body, '!verylarge')
309+ run : |
310+ echo "## Very Large Postgres payload run (5MB)" >> postgres-benchmark.md
311+ hyperfine --show-output --warmup 1 --export-markdown bench-postgres-vl.md -n 'postgres-main' './bench-main -resultsize 5000000 -runs 2 -backend postgres -timeout 240s' -n 'postgres-pr' './bench-pr -resultsize 5000000 -runs 2 -backend postgres -timeout 240s'
312+ cat bench-postgres-vl.md >> postgres-benchmark.md
313+
314+ - name : Upload Postgres benchmark results
315+ uses : actions/upload-artifact@v4
316+ with :
317+ name : postgres-results
318+ path : postgres-benchmark.md
319+
238320 combine-results :
239321 runs-on : ubuntu-latest
240- needs : [mysql-bench, sqlite-bench, redis-bench]
241- if : always() && (needs.mysql-bench.result == 'success' || needs.sqlite-bench.result == 'success' || needs.redis-bench.result == 'success') && github.event.issue.pull_request
322+ needs : [mysql-bench, sqlite-bench, redis-bench, postgres-bench ]
323+ if : always() && (needs.mysql-bench.result == 'success' || needs.sqlite-bench.result == 'success' || needs.redis-bench.result == 'success' || needs.postgres-bench.result == 'success' ) && github.event.issue.pull_request
242324 steps :
243325 - name : Download MySQL results
244326 if : needs.mysql-bench.result == 'success'
@@ -264,6 +346,14 @@ jobs:
264346 path : ./results
265347 continue-on-error : true
266348
349+ - name : Download Postgres results
350+ if : needs.postgres-bench.result == 'success'
351+ uses : actions/download-artifact@v4
352+ with :
353+ name : postgres-results
354+ path : ./results
355+ continue-on-error : true
356+
267357 - name : Combine benchmark results
268358 run : |
269359 echo "# Benchmark Results" > combined-benchmark.md
@@ -284,6 +374,11 @@ jobs:
284374 echo "" >> combined-benchmark.md
285375 fi
286376
377+ if [ -f "./results/postgres-benchmark.md" ]; then
378+ cat ./results/postgres-benchmark.md >> combined-benchmark.md
379+ echo "" >> combined-benchmark.md
380+ fi
381+
287382 - name : Write a new comment
288383 uses : peter-evans/create-or-update-comment@v2
289384 continue-on-error : true
0 commit comments