Performance notes¶
Smoke tests¶
FormatPerformanceSmokeTest asserts that formatting a large synthetic class (~800 methods) and many
small passes completes within generous wall-clock bounds on CI.
Corpus throughput comparison (:formatter-benchmark)¶
The Gradle module formatter-benchmark formats every .java file under PRINCE_BENCH_ROOT with
Prince of Space, Google Java Format (AOSP), Palantir Java Format (AOSP), Eclipse JDT (Spotless eclipse() / Equo), and optionally Prettier +
prettier-plugin-java (npx). Results are written to perf-results/spring-framework.md
(use PRINCE_BENCH_REPORT for another path).
Optional environment variables:
| Variable | Effect |
|---|---|
PRINCE_BENCH_WORKERS |
Parallel workers for JVM formatter legs (default 1). Same pool size is used for Prince, Google Java Format, Palantir, and Eclipse. |
PRINCE_BENCH_SKIP_ECLIPSE |
Set to true to skip the Eclipse JDT leg (no Equo P2 / Maven downloads). |
PRINCE_BENCH_MAVEN_CACHE |
Directory for the benchmark’s Maven Central jar cache (defaults to ~/.cache/prince-bench-m2). |
PRINCE_BENCH_P2_CACHE |
Equo P2 cache root (defaults to ~/.cache/prince-bench-eclipse-p2). |
PRINCE_BENCH_DIAGNOSTICS |
When true, sets -Dprince.bench.diagnostics=true for the strict Prince leg and appends phase-timing Markdown to the report. |
For faster local Gradle test execution only (not CI defaults), try ./gradlew :core:test --max-workers=6 -Ptest.maxParallelForks=2.
Google Java Format / Palantir need JDK-internal javac exports — the run task adds the standard
--add-exports flags (same idea as running those formatters on JDK 16+). Prettier rewrites the
checkout; use a disposable clone or set PRINCE_BENCH_SKIP_PRETTIER=true.
README automation¶
./gradlew assemblerunssyncReadmeVersionslocally so Gradle/Maven coordinates inREADME.mdtrackgradle.propertiesreadmeMavenCoordinatesVersion(latest release on Central, not the devversionline).- GitHub Actions sets
CI=true;syncReadmeVersions/syncReadmePerfSectionare skipped there unlessRUN_README_SYNC=true(avoids three parallel matrix jobs rewritingREADME.md). .github/workflows/readme-benchmark.yml(push tomain/master) clones Spring Framework, runs:formatter-benchmark:run, thensyncReadmePerfSection+syncReadmeVersions, and commitsREADME.md+docs/perf-results/spring-framework.mdwith[skip ci]so the bot push does not loop CI..github/workflows/sync-readme-versions.ymlruns the same coordinate sync whengradle.propertieschanges onmain/master.syncReadmePerfSectionreplaces the<!-- sync:perf:start -->…<!-- sync:perf:end -->block using the checked-in report file.
Future work¶
- Add a JMH subproject for steady-state throughput (lines/sec) and allocation profiles.
- Revisit
est()/ subtree string width estimates inPrincePrettyPrinterVisitorif profiling shows hot allocation fromtoString()on deep trees.