perf: add DD-061 benchmark harness#133
Conversation
Greptile SummaryThis PR implements the DD-061 benchmark harness (PR 2 of the performance roadmap): a Python script at
Confidence Score: 5/5Safe to merge — adds opt-in benchmark tooling and fixtures with no effect on CI or production paths. All changes are additive: a new Python harness, ntnt fixture files, HTML templates, and a doc update. Nothing touches production code paths, CI gates, or existing tests. The harness is guarded behind an explicit invocation and writes results only to target/perf-bench/. No files require special attention; the two minor logic gaps noted are in the benchmark reporting path only. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant User
participant Harness as run-benchmarks.py
participant Cargo
participant Server as ntnt server.tnt
participant WRK as wrk / urllib
participant CLI as ntnt compute_cli.tnt
participant FS as target/perf-bench/
User->>Harness: python3 run-benchmarks.py [--quick] [--include-db]
Harness->>Cargo: cargo build --profile dev-release
Cargo-->>Harness: ntnt binary
Harness->>Server: Popen(ntnt run server.tnt) + wait_for_server
Server-->>Harness: HTTP 2xx on /
loop for each HTTP benchmark
Harness->>WRK: run route (wrk -d Ns or urllib loop)
WRK-->>Harness: RPS / latency result
end
Harness->>Server: SIGTERM (killpg)
Harness->>CLI: ntnt run compute_cli.tnt x N runs
CLI-->>Harness: elapsed_ms, stdout
Harness->>FS: write ntnt-perf-stamp.json
Harness->>FS: write ntnt-perf-stamp.md
Harness-->>User: paths to JSON + Markdown output
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant User
participant Harness as run-benchmarks.py
participant Cargo
participant Server as ntnt server.tnt
participant WRK as wrk / urllib
participant CLI as ntnt compute_cli.tnt
participant FS as target/perf-bench/
User->>Harness: python3 run-benchmarks.py [--quick] [--include-db]
Harness->>Cargo: cargo build --profile dev-release
Cargo-->>Harness: ntnt binary
Harness->>Server: Popen(ntnt run server.tnt) + wait_for_server
Server-->>Harness: HTTP 2xx on /
loop for each HTTP benchmark
Harness->>WRK: run route (wrk -d Ns or urllib loop)
WRK-->>Harness: RPS / latency result
end
Harness->>Server: SIGTERM (killpg)
Harness->>CLI: ntnt run compute_cli.tnt x N runs
CLI-->>Harness: elapsed_ms, stdout
Harness->>FS: write ntnt-perf-stamp.json
Harness->>FS: write ntnt-perf-stamp.md
Harness-->>User: paths to JSON + Markdown output
Reviews (2): Last reviewed commit: "fix: address benchmark review diagnostic..." | Re-trigger Greptile |
Summary
scripts/bench/run-benchmarks.py.examples/perf/for plaintext, JSON, route params, compute loop, templates/partials/loops, CLI compute, and optional PostgreSQL routes.Notes
--include-dbandDATABASE_URL.target/perf-bench/as JSON and Markdown.Verification
python3AST parse forscripts/bench/run-benchmarks.py./target/dev-release/ntnt validate examples/perf./target/dev-release/ntnt lint examples/perf --strict(suggestions only: missing contracts in perf fixture functions)python3 scripts/bench/run-benchmarks.py --quick --duration 1python3 scripts/bench/run-benchmarks.py --duration 500msrejects unsupported duration unitsgit diff --check