Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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':
Expand Down Expand Up @@ -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
}
42 changes: 42 additions & 0 deletions test/write.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down