Skip to content

Commit a0f178f

Browse files
committed
bench(gradle): configure JMH via plugin for CI-appropriate defaults
1 parent e211b38 commit a0f178f

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

examples/example-gradle/build.gradle.kts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,30 @@ version = "1.0-SNAPSHOT"
99
jmh {
1010
jmhVersion.set("0.1.0")
1111

12+
benchmarkMode.set(listOf("avgt"))
13+
timeUnit.set("ns")
14+
warmupIterations.set(2)
15+
warmup.set("1s")
16+
iterations.set(3)
17+
timeOnIteration.set("1s")
18+
fork.set(3)
19+
resultFormat.set("JSON")
20+
1221
// Force a System.gc() between iterations so heap state is reset before each
1322
// measurement starts. Without this, a GC pause can land inside the measurement
1423
// window and show up as a spurious regression in CI.
1524
forceGC = true
25+
26+
// Run subset of the benchmarks to avoid long CI runtimes
27+
if (System.getenv("CODSPEED_ENV") != null) {
28+
logger.lifecycle("CODSPEED_ENV detected — running curated CI benchmark subset")
29+
// me.champeau.jmh joins `includes` with commas into a single positional
30+
// regex passed to JMH, so multiple entries collapse to one pattern with
31+
// literal commas and match nothing. Use a single alternation instead.
32+
includes.set(listOf(
33+
".*(SleepBenchmark|BacktrackingBenchmark|FibBenchmark).*",
34+
))
35+
}
1636
}
1737

1838
sourceSets {

0 commit comments

Comments
 (0)