Skip to content

add :benchmarks module comparing kmapper vs hand-written mappings#29

Merged
wilmveel merged 3 commits into
mainfrom
claude/add-performance-benchmarks-PApk6
Apr 25, 2026
Merged

add :benchmarks module comparing kmapper vs hand-written mappings#29
wilmveel merged 3 commits into
mainfrom
claude/add-performance-benchmarks-PApk6

Conversation

@wilmveel

Copy link
Copy Markdown
Contributor

Measures runtime overhead of kmapper-generated code against equivalent
hand-written constructor calls for two scenarios — a flat 3-field mapping
and a nested mapping with value classes, a list, an enum, and a numeric
widening.

Two runners are provided:

  • JMH via kotlinx-benchmark for authoritative ns/op numbers
  • A standalone System.nanoTime() runner for a zero-friction sanity check

The module applies the kmapper Gradle plugin to its own sources, so it
needs the plugin in mavenLocal at configuration time. To avoid breaking
the parent build before that bootstrap publish has happened, :benchmarks
is gated behind -Pkmapper.benchmarks=true. The README documents the
two-step workflow.

claude added 3 commits April 25, 2026 11:25
Measures runtime overhead of kmapper-generated code against equivalent
hand-written constructor calls for two scenarios — a flat 3-field mapping
and a nested mapping with value classes, a list, an enum, and a numeric
widening.

Two runners are provided:
- JMH via kotlinx-benchmark for authoritative ns/op numbers
- A standalone System.nanoTime() runner for a zero-friction sanity check

The module applies the kmapper Gradle plugin to its own sources, so it
needs the plugin in mavenLocal at configuration time. To avoid breaking
the parent build before that bootstrap publish has happened, :benchmarks
is gated behind -Pkmapper.benchmarks=true. The README documents the
two-step workflow.
Adds a `verifyBenchmarkThresholds` Gradle task that parses the JMH JSON
report and fails the build if any kmapper benchmark is more than
`benchmarkMaxRatio`x slower than its hand-written counterpart (default 5x).
Wires the task into a new `benchmarks` job in build.yml that publishes the
plugin artifacts to mavenLocal, runs the threshold gate, and uploads the
JMH report as an artifact.

The 5x default is loose on purpose: GitHub-hosted runners share CPUs and
don't pin frequency, so single-digit-percent variance is normal. The gate
catches catastrophic regressions (broken codegen, accidental reflection)
without flaking on noise. Tighter ratios can be set locally via
`-PbenchmarkMaxRatio=2.0`.

Also makes warmups/iterations configurable via `-PbenchmarkWarmups` /
`-PbenchmarkIterations` so the same task serves both the fast CI smoke
and a slow-but-trustworthy local run.
Adds a short Performance section linking to the new :benchmarks module
and explaining the 5x CI threshold gate.
@wilmveel wilmveel merged commit ae1d098 into main Apr 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants