1- name : Benchmark
1+ name : Framework Comparison
22
33on :
4- # Run on PRs to compare performance
5- pull_request :
6- paths :
7- - ' packages/**'
8- - ' benchmark/**'
9- # Manual trigger
4+ push :
5+ tags :
6+ - ' v*'
107 workflow_dispatch :
118 inputs :
12- suite :
13- description : ' Benchmark suite to run '
9+ frameworks :
10+ description : ' Frameworks to test (comma-separated, or "all") '
1411 required : false
1512 default : ' all'
16- type : choice
17- options :
18- - all
19- - micro
20- - memory
21- - streaming
22- # Weekly scheduled run for tracking
23- schedule :
24- - cron : ' 0 0 * * 0' # Every Sunday at midnight
13+ scenarios :
14+ description : ' Scenarios to run (comma-separated, or "all")'
15+ required : false
16+ default : ' trivial,table100,table500'
2517
2618jobs :
27- benchmark-native :
28- name : Native Benchmarks
19+ benchmark-frameworks :
20+ name : Compare Frameworks
2921 runs-on : ubuntu-latest
3022
3123 steps :
@@ -37,106 +29,69 @@ jobs:
3729 ocaml-compiler : 5.2.x
3830 dune-cache : true
3931
40- - name : Install dependencies
41- run : opam install . --deps-only --with-test -y
32+ - name : Setup Node.js
33+ uses : actions/setup-node@v4
34+ with :
35+ node-version : ' 20'
4236
43- - name : Build benchmark scenarios
44- run : opam exec -- dune build benchmark/scenarios/benchmark_scenarios.a
37+ - name : Setup Bun
38+ uses : oven-sh/setup-bun@v1
4539
46- - name : Build benchmark executables
40+ - name : Install wrk
4741 run : |
48- opam exec -- dune build benchmark/micro/micro_bench.exe
49- opam exec -- dune build benchmark/memory/memory_bench.exe
50- opam exec -- dune build benchmark/streaming/streaming_bench.exe
42+ sudo apt-get update
43+ sudo apt-get install -y wrk
5144
52- - name : Run Memory Benchmark
53- id : memory
54- run : |
55- echo "## Memory Benchmark Results" >> $GITHUB_STEP_SUMMARY
56- echo '```' >> $GITHUB_STEP_SUMMARY
57- opam exec -- _build/default/benchmark/memory/memory_bench.exe 2>&1 | tee memory-results.txt
58- cat memory-results.txt >> $GITHUB_STEP_SUMMARY
59- echo '```' >> $GITHUB_STEP_SUMMARY
60-
61- - name : Run Streaming Benchmark
62- id : streaming
63- run : |
64- echo "## Streaming Benchmark Results" >> $GITHUB_STEP_SUMMARY
65- echo '```' >> $GITHUB_STEP_SUMMARY
66- opam exec -- _build/default/benchmark/streaming/streaming_bench.exe 2>&1 | tee streaming-results.txt
67- cat streaming-results.txt >> $GITHUB_STEP_SUMMARY
68- echo '```' >> $GITHUB_STEP_SUMMARY
69-
70- - name : Run Microbenchmark (Quick)
71- id : micro
72- run : |
73- echo "## Microbenchmark Results (Table Suite)" >> $GITHUB_STEP_SUMMARY
74- echo '```' >> $GITHUB_STEP_SUMMARY
75- opam exec -- _build/default/benchmark/micro/micro_bench.exe table 2>&1 | tee micro-results.txt
76- cat micro-results.txt >> $GITHUB_STEP_SUMMARY
77- echo '```' >> $GITHUB_STEP_SUMMARY
45+ - name : Install OCaml dependencies
46+ run : opam install . --deps-only -y
7847
79- - name : Upload Results
80- uses : actions/upload-artifact@v4
81- with :
82- name : benchmark-results-${{ github.sha }}
83- path : |
84- memory-results.txt
85- streaming-results.txt
86- micro-results.txt
87- retention-days : 30
88-
89- benchmark-compare :
90- name : Compare with Base Branch
91- runs-on : ubuntu-latest
92- if : github.event_name == 'pull_request'
48+ - name : Build native server
49+ run : opam exec -- dune build benchmark/native/server.exe --profile=release
9350
94- steps :
95- - uses : actions/checkout@v4
96- with :
97- fetch-depth : 0
51+ - name : Install JS framework dependencies
52+ working-directory : benchmark/frameworks
53+ run : npm install
9854
99- - name : Setup OCaml
100- uses : ocaml/setup-ocaml@v3
101- with :
102- ocaml-compiler : 5.2.x
103- dune-cache : true
55+ - name : Install runner dependencies
56+ working-directory : benchmark/runner
57+ run : npm install
10458
105- - name : Install dependencies
106- run : opam install . --deps-only --with-test -y
59+ - name : Start native server
60+ run : |
61+ opam exec -- _build/default/benchmark/native/server.exe &
62+ sleep 2
10763
108- - name : Benchmark PR branch
64+ - name : Run framework comparison
65+ working-directory : benchmark/runner
10966 run : |
110- opam exec -- dune build benchmark/memory/memory_bench.exe
111- opam exec -- _build/default/benchmark/memory/memory_bench.exe --json > pr-results.json
67+ FRAMEWORKS="${{ github.event.inputs.frameworks || 'all' }}"
68+ SCENARIOS="${{ github.event.inputs.scenarios || 'trivial,table100,table500' }}"
11269
113- - name : Checkout base branch
114- run : git checkout ${{ github.base_ref }}
70+ ARGS=""
71+ if [ "$FRAMEWORKS" != "all" ]; then
72+ ARGS="$ARGS --frameworks $FRAMEWORKS"
73+ fi
74+ if [ "$SCENARIOS" != "all" ]; then
75+ ARGS="$ARGS --scenarios $SCENARIOS"
76+ fi
11577
116- - name : Benchmark base branch
117- run : |
118- opam exec -- dune clean
119- opam exec -- dune build benchmark/memory/memory_bench.exe
120- opam exec -- _build/default/benchmark/memory/memory_bench.exe --json > base-results.json
121- continue-on-error : true
78+ node runner.mjs $ARGS
79+
80+ - name : Upload results
81+ uses : actions/upload-artifact@v4
82+ with :
83+ name : framework-comparison-${{ github.sha }}
84+ path : benchmark/runner/results/
85+ retention-days : 90
12286
123- - name : Compare Results
87+ - name : Add results to summary
12488 run : |
125- echo "## Performance Comparison" >> $GITHUB_STEP_SUMMARY
89+ echo "## Framework Comparison Results " >> $GITHUB_STEP_SUMMARY
12690 echo "" >> $GITHUB_STEP_SUMMARY
127- if [ -f base-results.json ] && [ -f pr-results.json ]; then
128- echo "Comparing memory allocations between base and PR..." >> $GITHUB_STEP_SUMMARY
129- # Simple comparison - in production you'd use a proper tool
130- echo "Base branch results:" >> $GITHUB_STEP_SUMMARY
131- echo '```json' >> $GITHUB_STEP_SUMMARY
132- cat base-results.json >> $GITHUB_STEP_SUMMARY
133- echo '```' >> $GITHUB_STEP_SUMMARY
134- echo "" >> $GITHUB_STEP_SUMMARY
135- echo "PR branch results:" >> $GITHUB_STEP_SUMMARY
136- echo '```json' >> $GITHUB_STEP_SUMMARY
137- cat pr-results.json >> $GITHUB_STEP_SUMMARY
138- echo '```' >> $GITHUB_STEP_SUMMARY
91+ LATEST=$(ls -t benchmark/runner/results/*.md 2>/dev/null | head -1)
92+ if [ -n "$LATEST" ]; then
93+ cat "$LATEST" >> $GITHUB_STEP_SUMMARY
13994 else
140- echo "⚠️ Could not compare - base branch benchmark may not exist " >> $GITHUB_STEP_SUMMARY
95+ echo "No results generated " >> $GITHUB_STEP_SUMMARY
14196 fi
14297
0 commit comments