Skip to content

Commit fa3e163

Browse files
committed
Add release benchmark docs
1 parent 307fa6a commit fa3e163

31 files changed

Lines changed: 3671 additions & 1 deletion

.github/workflows/generated-docs-sync.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ on:
1515
- 'scripts/build_schema_docs.py'
1616
- 'scripts/build_conformance_docs.py'
1717
- 'scripts/build_architecture_docs.py'
18+
- 'scripts/build_release_benchmark_docs.py'
1819
- 'scripts/build_llms_txt.py'
1920
- 'scripts/update_generate_prompt_snapshots.py'
2021
- 'scripts/update_docs_version.py'
22+
- 'docs/data/release-benchmarks.json'
23+
- 'docs/assets/benchmarks/release-benchmarks.svg'
2124
- 'tox.ini'
2225
- '.github/workflows/generated-docs-sync.yaml'
2326
- 'docs/**/*.md'
@@ -66,6 +69,8 @@ jobs:
6669
docs/presets.md
6770
docs/conformance.md
6871
docs/architecture.md
72+
docs/performance-benchmarks.md
73+
docs/assets/benchmarks/release-benchmarks.svg
6974
docs/cli-reference/
7075
docs/llms.txt
7176
docs/llms-full.txt

.github/workflows/llms-txt.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ on:
1313
- 'scripts/build_preset_docs.py'
1414
- 'src/datamodel_code_generator/parser/schema_version.py'
1515
- 'scripts/build_schema_docs.py'
16+
- 'scripts/build_release_benchmark_docs.py'
17+
- 'docs/data/release-benchmarks.json'
18+
- 'docs/assets/benchmarks/release-benchmarks.svg'
1619
- 'docs/**/*.md'
1720
- 'README.md'
1821
- 'zensical.toml'
@@ -67,5 +70,7 @@ jobs:
6770
run: .tox/schema-docs/bin/python scripts/build_schema_docs.py
6871
- name: Build preset docs
6972
run: .tox/preset-docs/bin/python scripts/build_preset_docs.py
73+
- name: Build release benchmark docs
74+
run: .tox/llms-txt/bin/python scripts/build_release_benchmark_docs.py
7075
- name: Build llms.txt
7176
run: .tox/llms-txt/bin/python scripts/build_llms_txt.py
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
name: Release Benchmarks
2+
3+
on:
4+
pull_request:
5+
types: [labeled, synchronize]
6+
workflow_run:
7+
workflows: ["Publish"]
8+
types: [completed]
9+
workflow_dispatch:
10+
inputs:
11+
versions:
12+
description: "Release tags or versions to benchmark. Leave empty to select by PyPI download usage."
13+
required: false
14+
default: ""
15+
history_days:
16+
description: "PyPI download lookback window used for version selection."
17+
required: false
18+
default: "365"
19+
limit:
20+
description: "Maximum release versions to benchmark."
21+
required: false
22+
default: "40"
23+
runs:
24+
description: "Measured runs per release/input/formatter case."
25+
required: false
26+
default: "7"
27+
python_version:
28+
description: "Python version used to install and run released packages."
29+
required: false
30+
default: "3.14.2"
31+
32+
concurrency:
33+
group: release-benchmarks-${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.ref }}
34+
cancel-in-progress: false
35+
36+
permissions:
37+
contents: read
38+
39+
jobs:
40+
resolve:
41+
name: Resolve release benchmark versions
42+
runs-on: ubuntu-24.04
43+
if: >-
44+
${{
45+
github.event_name == 'workflow_dispatch' ||
46+
(
47+
github.event_name == 'pull_request' &&
48+
contains(github.event.pull_request.labels.*.name, 'run-release-benchmarks') &&
49+
github.event.pull_request.head.repo.full_name == github.repository
50+
) ||
51+
(
52+
github.event.workflow_run.conclusion == 'success' &&
53+
github.event.workflow_run.event == 'push' &&
54+
github.event.workflow_run.head_repository.full_name == github.repository
55+
)
56+
}}
57+
outputs:
58+
versions_json: ${{ steps.versions.outputs.versions_json }}
59+
versions: ${{ steps.versions.outputs.versions }}
60+
env:
61+
BENCHMARK_PYTHON_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.python_version || '3.14.2' }}
62+
BENCHMARK_HISTORY_DAYS: ${{ github.event_name == 'workflow_dispatch' && inputs.history_days || '365' }}
63+
BENCHMARK_LIMIT: ${{ github.event_name == 'workflow_dispatch' && inputs.limit || '40' }}
64+
steps:
65+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
66+
with:
67+
persist-credentials: false
68+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
69+
with:
70+
python-version: ${{ env.BENCHMARK_PYTHON_VERSION }}
71+
- name: Resolve release versions
72+
id: versions
73+
env:
74+
EVENT_NAME: ${{ github.event_name }}
75+
WORKFLOW_TAG: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || '' }}
76+
INPUT_VERSIONS: ${{ github.event_name == 'workflow_dispatch' && inputs.versions || '' }}
77+
run: |
78+
set -euo pipefail
79+
versions="$INPUT_VERSIONS"
80+
if [ "$EVENT_NAME" = "workflow_run" ]; then
81+
versions="$WORKFLOW_TAG"
82+
fi
83+
python scripts/select_release_benchmark_versions.py \
84+
--versions "$versions" \
85+
--history-days "$BENCHMARK_HISTORY_DAYS" \
86+
--limit "$BENCHMARK_LIMIT" \
87+
--output .benchmarks/release-benchmark-selection.json
88+
- name: Upload benchmark selection
89+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
90+
with:
91+
name: dcg-release-benchmark-selection
92+
path: .benchmarks/release-benchmark-selection.json
93+
if-no-files-found: error
94+
95+
collect:
96+
name: Collect release benchmarks (${{ matrix.version }})
97+
needs: resolve
98+
if: needs.resolve.result == 'success'
99+
runs-on: ubuntu-24.04
100+
strategy:
101+
fail-fast: false
102+
max-parallel: 40
103+
matrix:
104+
version: ${{ fromJson(needs.resolve.outputs.versions_json) }}
105+
env:
106+
BENCHMARK_PYTHON_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.python_version || '3.14.2' }}
107+
BENCHMARK_RUNS: ${{ github.event_name == 'workflow_dispatch' && inputs.runs || (github.event_name == 'pull_request' && '3' || '7') }}
108+
OS: ubuntu-24.04
109+
steps:
110+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
111+
with:
112+
persist-credentials: false
113+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
114+
with:
115+
python-version: ${{ env.BENCHMARK_PYTHON_VERSION }}
116+
- name: Install the latest version of uv
117+
uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5
118+
- name: Collect benchmarks
119+
env:
120+
BENCHMARK_VERSION: ${{ matrix.version }}
121+
run: >-
122+
python scripts/collect_release_benchmarks.py
123+
--versions "$BENCHMARK_VERSION"
124+
--runs "$BENCHMARK_RUNS"
125+
--output ".benchmarks/fragments/release-benchmark-${BENCHMARK_VERSION}.json"
126+
- name: Upload benchmark fragment
127+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
128+
with:
129+
name: dcg-release-benchmark-fragment-${{ matrix.version }}
130+
path: .benchmarks/fragments/release-benchmark-${{ matrix.version }}.json
131+
if-no-files-found: error
132+
133+
build:
134+
name: Build release benchmark docs artifact
135+
needs: [resolve, collect]
136+
if: needs.collect.result == 'success'
137+
runs-on: ubuntu-24.04
138+
env:
139+
BENCHMARK_PYTHON_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.python_version || '3.14.2' }}
140+
OS: ubuntu-24.04
141+
steps:
142+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
143+
with:
144+
persist-credentials: false
145+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
146+
with:
147+
python-version: ${{ env.BENCHMARK_PYTHON_VERSION }}
148+
- name: Download benchmark selection
149+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
150+
with:
151+
name: dcg-release-benchmark-selection
152+
path: .benchmarks
153+
- name: Download benchmark fragments
154+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
155+
with:
156+
pattern: dcg-release-benchmark-fragment-*
157+
path: .benchmarks/fragments
158+
merge-multiple: true
159+
- name: Merge benchmark data
160+
run: >-
161+
python scripts/merge_release_benchmarks.py
162+
.benchmarks/fragments/*.json
163+
--selection .benchmarks/release-benchmark-selection.json
164+
--output .benchmarks/release-benchmarks.json
165+
- name: Build benchmark docs artifact
166+
run: >-
167+
python scripts/build_release_benchmark_docs.py
168+
--data .benchmarks/release-benchmarks.json
169+
--docs .benchmarks/docs/performance-benchmarks.md
170+
--svg .benchmarks/docs/assets/benchmarks/release-benchmarks.svg
171+
- name: Upload benchmark data
172+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
173+
with:
174+
name: dcg-release-benchmarks-json
175+
path: .benchmarks/release-benchmarks.json
176+
if-no-files-found: error
177+
- name: Upload benchmark docs
178+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
179+
with:
180+
name: dcg-release-benchmark-docs
181+
path: .benchmarks/docs
182+
if-no-files-found: error

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ Custom templates can emit Python outside the standard generated model patterns c
199199
custom-template output is not exhaustively validated. If `--formatters builtin` produces invalid or poorly formatted
200200
output with a custom template, please open an issue with a small reproducer. See
201201
[Formatter Behavior](https://datamodel-code-generator.koxudaxi.dev/formatter-behavior/) for details.
202+
203+
See [Performance Benchmarks](https://datamodel-code-generator.koxudaxi.dev/performance-benchmarks/) for release benchmark data and SVG charts.
202204
<!-- END AUTO-GENERATED PRESET QUICK START -->
203205

204206
---
@@ -213,6 +215,7 @@ output with a custom template, please open an issue with a small reproducer. See
213215
- ⚙️ [pyproject.toml](https://datamodel-code-generator.koxudaxi.dev/pyproject_toml/) - Configuration file
214216
- 🔄 [CI/CD Integration](https://datamodel-code-generator.koxudaxi.dev/ci-cd/) - GitHub Actions, pre-commit hooks
215217
-[Conformance Dashboard](https://datamodel-code-generator.koxudaxi.dev/conformance/) - External corpus coverage signals
218+
- 📈 [Performance Benchmarks](https://datamodel-code-generator.koxudaxi.dev/performance-benchmarks/) - Release benchmark tables and SVG charts
216219
- 🧭 [Architecture](https://datamodel-code-generator.koxudaxi.dev/architecture/) - Generation pipeline and synchronized component inventory
217220
- 🚀 [One-liner Usage](https://datamodel-code-generator.koxudaxi.dev/oneliner/) - uvx, pipx, clipboard integration
218221
-[FAQ](https://datamodel-code-generator.koxudaxi.dev/faq/) - Common questions
Lines changed: 68 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)