From 94d44ed49329541b5e830dcf783c7ab45ad54c6f Mon Sep 17 00:00:00 2001 From: lixiaoyong Date: Tue, 25 Aug 2026 10:27:49 +0800 Subject: [PATCH 1/2] fix: handle JMH throughput metrics as bigger-is-better --- src/write.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/write.ts b/src/write.ts index 4e9ebad6c..24ea6ccd2 100644 --- a/src/write.ts +++ b/src/write.ts @@ -60,7 +60,7 @@ async function addIndexHtmlIfNeeded(additionalGitArguments: string[], dir: strin console.log('Created default index.html at', indexHtmlFullPath); } -function biggerIsBetter(tool: ToolType): boolean { +function biggerIsBetter(tool: ToolType, result: BenchmarkResult): boolean { switch (tool) { case 'cargo': return false; @@ -79,7 +79,7 @@ function biggerIsBetter(tool: ToolType): boolean { case 'julia': return false; case 'jmh': - return false; + return result.unit.toLowerCase().startsWith('ops/'); case 'benchmarkdotnet': return false; case 'customBiggerIsBetter': @@ -548,7 +548,7 @@ async function handleSummary(benchName: string, currBench: Benchmark, prevBench: function getRatio(tool: ToolType, prev: BenchmarkResult, current: BenchmarkResult) { if (prev.value === 0 && current.value === 0) return 1; - return biggerIsBetter(tool) + return biggerIsBetter(tool, current) ? prev.value / current.value // e.g. current=100, prev=200 : current.value / prev.value; // e.g. current=200, prev=100 } From 961df54bca5c66eaf17997eb74fd08b3e0782830 Mon Sep 17 00:00:00 2001 From: lixiaoyong Date: Tue, 25 Aug 2026 10:27:54 +0800 Subject: [PATCH 2/2] test: cover mixed JMH metric directions --- test/write.spec.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/write.spec.ts b/test/write.spec.ts index 1cf7ce729..76e4cb04b 100644 --- a/test/write.spec.ts +++ b/test/write.spec.ts @@ -503,6 +503,48 @@ describe.each(['https://github.com', 'https://github.enterprise.corp'])('writeBe 'CC: @user', ], }, + { + it: 'raises alerts for both throughput and time JMH benchmarks', + config: defaultCfg, + data: { + lastUpdate, + repoUrl, + entries: { + 'Test benchmark': [ + { + commit: commit('prev commit id'), + date: lastUpdate - 1000, + tool: 'jmh', + benches: [ + bench('throughput', 100, '± 20', 'ops/s'), + bench('averageTime', 100, '± 20', 'ns/op'), + ], + }, + ], + }, + }, + added: { + commit: commit('current commit id'), + date: lastUpdate, + tool: 'jmh', + benches: [bench('throughput', 20, '± 20', 'ops/s'), bench('averageTime', 210, '± 20', 'ns/op')], + }, + error: [ + '# :warning: **Performance Alert** :warning:', + '', + "Possible performance regression was detected for benchmark **'Test benchmark'**.", + 'Benchmark result of this commit is worse than the previous benchmark result exceeding threshold `2`.', + '', + '| Benchmark suite | Current: current commit id | Previous: prev commit id | Ratio |', + '|-|-|-|-|', + '| `throughput` | `20` ops/s (`± 20`) | `100` ops/s (`± 20`) | `5` |', + '| `averageTime` | `210` ns/op (`± 20`) | `100` ns/op (`± 20`) | `2.10` |', + '', + `This comment was automatically generated by [workflow](${serverUrl}/user/repo/actions?query=workflow%3AWorkflow%20name) using [github-action-benchmark](https://github.com/marketplace/actions/continuous-benchmark).`, + '', + 'CC: @user', + ], + }, { it: 'raises an alert without benchmark name with default benchmark name', config: { ...defaultCfg, name: 'Benchmark' },