-
Notifications
You must be signed in to change notification settings - Fork 7
134 lines (115 loc) · 3.89 KB
/
Copy pathbenchmarks.yml
File metadata and controls
134 lines (115 loc) · 3.89 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
name: Benchmarks
on:
pull_request:
paths:
- "tesseract_core/**"
- "benchmarks/**"
- ".github/workflows/benchmarks.yml"
- "benchmarks/compare_benchmarks.py"
push:
branches:
- main
paths:
- "tesseract_core/**"
- "benchmarks/**"
- ".github/workflows/benchmarks.yml"
- "benchmarks/compare_benchmarks.py"
concurrency:
group: benchmarks-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
benchmark:
runs-on: ubuntu-latest
steps:
- name: Set up Git repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Set up uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Restore UV environment
run: cp production.uv.lock uv.lock
- name: Install package
run: uv sync --extra dev --frozen
- name: Run benchmarks on current commit
run: |
uv run --no-sync python benchmarks/run_benchmarks.py \
--iterations 10 \
--array-sizes 100,10000,1000000 \
--output current_benchmarks.json
- name: Check out baseline branch
if: github.event_name == 'pull_request'
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.base.ref }}
path: baseline
- name: Install package (baseline)
if: github.event_name == 'pull_request'
working-directory: baseline
run: |
cp production.uv.lock uv.lock 2>/dev/null || true
uv sync --extra dev --frozen
- name: Run benchmarks on baseline
if: github.event_name == 'pull_request'
id: baseline
working-directory: baseline
run: |
if [ -f benchmarks/run_benchmarks.py ]; then
uv run --no-sync python benchmarks/run_benchmarks.py \
--iterations 10 \
--array-sizes 100,10000,1000000 \
--output baseline_benchmarks.json
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "::notice::Benchmark script not found in baseline, skipping comparison"
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Generate comparison report
if: github.event_name == 'pull_request'
id: comparison
run: |
python benchmarks/compare_benchmarks.py \
baseline/baseline_benchmarks.json \
current_benchmarks.json \
benchmark_report.md
# Set output as multiline string
{
echo 'report<<BENCHMARK_REPORT_END'
cat benchmark_report.md
echo ''
echo 'BENCHMARK_REPORT_END'
} >> $GITHUB_OUTPUT
- name: Find existing comment
if: github.event_name == 'pull_request'
uses: peter-evans/find-comment@v3
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "PasteurBot"
body-includes: "## Benchmark Results"
- name: Create or update PR comment
if: github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ secrets.PL_PASTEURBOT_PAT_PUBLIC }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.comparison.outputs.report }}
edit-mode: replace
- name: Upload benchmark results
uses: actions/upload-artifact@v7
with:
name: benchmark-results
path: |
current_benchmarks.json
baseline/baseline_benchmarks.json
benchmark_report.md
if-no-files-found: ignore
retention-days: 30