-
Notifications
You must be signed in to change notification settings - Fork 2
168 lines (144 loc) · 5.72 KB
/
benchmark.yml
File metadata and controls
168 lines (144 loc) · 5.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: Performance Benchmark
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: write
issues: write
pull-requests: write
concurrency:
group: benchmark-${{ github.ref }}
cancel-in-progress: true
env:
PHP_VERSION: '8.3'
BENCHMARK_DOCS: 10000
BENCHMARK_DIMS: 128
jobs:
# ─────────────────────────────────────────────────────────────────────────────
# PR Benchmark: Compare PR against baseline from gh-pages
# ─────────────────────────────────────────────────────────────────────────────
benchmark-pr:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
name: PR Performance Comparison
steps:
- name: Checkout PR branch
uses: actions/checkout@v5
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
coverage: none
ini-values: memory_limit=2G
- name: Cache Composer packages
uses: actions/cache@v5
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-dev
- name: Detect benchmark profile
id: profile
run: |
SCENARIOS="xs,small"
if ${{ contains(github.event.pull_request.labels.*.name, 'benchmark-full') }}; then
SCENARIOS="xs,small,medium,large,highdim"
fi
echo "scenarios=$SCENARIOS" >> "$GITHUB_OUTPUT"
- name: Run benchmark
run: |
php benchmark/run.php \
--profile=ci \
--scenarios=${{ steps.profile.outputs.scenarios }} \
--documents=${{ env.BENCHMARK_DOCS }} \
--dimensions=${{ env.BENCHMARK_DIMS }} \
--github-bench=pr-benchmark.json
- name: Fetch baseline from gh-pages
run: |
git fetch origin gh-pages --depth=1 2>/dev/null || true
git show origin/gh-pages:docs/benchmark/latest.json > baseline.json 2>/dev/null || echo "[]" > baseline.json
- name: Compare benchmarks
run: |
php benchmark/compare.php \
--baseline=baseline.json \
--current=pr-benchmark.json \
--output=comparison.md
- name: Post benchmark comparison
if: always()
uses: marocchino/sticky-pull-request-comment@v2
with:
header: benchmark
path: comparison.md
- name: Upload benchmark artifacts
if: always()
uses: actions/upload-artifact@v5
with:
name: benchmark-results-pr
path: |
pr-benchmark.json
baseline.json
comparison.md
retention-days: 14
# ─────────────────────────────────────────────────────────────────────────────
# Main Benchmark: Store historical data and update graphs
# ─────────────────────────────────────────────────────────────────────────────
benchmark-main:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
name: Store Benchmark History
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
coverage: none
ini-values: memory_limit=1G
- name: Cache Composer packages
uses: actions/cache@v5
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-dev
- name: Run benchmark
run: |
php benchmark/run.php \
--profile=ci \
--scenarios=small \
--documents=${{ env.BENCHMARK_DOCS }} \
--dimensions=${{ env.BENCHMARK_DIMS }} \
--github-bench=benchmark-results.json
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
name: PHPVector Performance
tool: customBiggerIsBetter
output-file-path: benchmark-results.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
benchmark-data-dir-path: docs/benchmark
comment-on-alert: true
alert-threshold: '150%'
fail-on-alert: false
- name: Commit baseline to gh-pages
run: |
git fetch origin gh-pages --depth=1 2>/dev/null || true
git worktree add /tmp/gh-pages gh-pages 2>/dev/null || git worktree add /tmp/gh-pages -b gh-pages
mkdir -p /tmp/gh-pages/docs/benchmark
cp benchmark-results.json /tmp/gh-pages/docs/benchmark/latest.json
cd /tmp/gh-pages
git add docs/benchmark/latest.json
git diff --cached --quiet || git commit -m "Update benchmark baseline"
git push origin gh-pages || true
cd -
git worktree remove /tmp/gh-pages
- name: Upload benchmark artifact
uses: actions/upload-artifact@v5
with:
name: benchmark-results-main
path: benchmark-results.json
retention-days: 90