add :benchmarks module comparing kmapper vs hand-written mappings#29
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.