Skip to content

fix: handle JMH throughput metrics as bigger-is-better - #366

Open
lixiaoyong01 wants to merge 2 commits into
benchmark-action:masterfrom
lixiaoyong01:fix/jmh-throughput-alerts
Open

fix: handle JMH throughput metrics as bigger-is-better#366
lixiaoyong01 wants to merge 2 commits into
benchmark-action:masterfrom
lixiaoyong01:fix/jmh-throughput-alerts

Conversation

@lixiaoyong01

@lixiaoyong01 lixiaoyong01 commented Aug 25, 2026

Copy link
Copy Markdown

Summary

JMH can report both throughput metrics (for example, ops/s) and
time-per-operation metrics (for example, ns/op) in the same benchmark
suite. The action previously treated all JMH results as smaller-is-better,
which inverted alert direction for throughput metrics.

This change derives the comparison direction from each result's unit:

  • ops/... units are treated as bigger-is-better.
  • Time-per-operation units retain the existing smaller-is-better behavior.

Fixes #365.

Tests

  • npm test -- --runInBand

The full suite passed locally: 235/235 tests on this branch. The two added
tests cover the mixed JMH throughput/time case for both GitHub.com and
GitHub Enterprise Server test configurations.

Summary by CodeRabbit

  • Bug Fixes

    • JMH benchmark comparisons now correctly identify throughput metrics, ensuring performance alerts are calculated accurately.
    • Alerts now work correctly for both throughput and timing-based JMH benchmarks.
  • Tests

    • Added coverage validating alerts and ratio calculations for JMH throughput and average-time results.

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f2a0ad44-2f8e-46e8-8f2c-427abcaaa102

📥 Commits

Reviewing files that changed from the base of the PR and between 86d8bcf and 961df54.

📒 Files selected for processing (2)
  • src/write.ts
  • test/write.spec.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

JMH ratio calculation now derives alert direction from each result unit. Throughput results use higher-is-better logic, while time results retain lower-is-better logic. A test covers both result types in one alert.

Changes

JMH alert direction

Layer / File(s) Summary
Unit-based ratio direction and coverage
src/write.ts, test/write.spec.ts
biggerIsBetter uses the result unit to identify ops/ throughput benchmarks. getRatio passes the current result. The test verifies alerts for both throughput and time JMH benchmarks.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 961df

This PR corrects comparison direction for JMH throughput metrics while preserving time-based behavior, with tests covering the mixed-metric cases; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: correcting JMH throughput metric handling so higher values are treated as better.
Linked Issues check ✅ Passed The implementation derives JMH comparison direction from the result unit. Units beginning with "ops/" are treated as bigger-is-better, while other JMH units retain smaller-is-better behavior. The adde…
Out of Scope Changes check ✅ Passed All changes are within scope. The source update fixes JMH comparison direction, and the test validates mixed throughput and time metrics.
Full details: Linked Issues check

Explanation

The implementation derives JMH comparison direction from the result unit. Units beginning with "ops/" are treated as bigger-is-better, while other JMH units retain smaller-is-better behavior. The added test covers both throughput and time metrics required by issue #365.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

JMH tool: biggerIsBetter is hardcoded false, inverting alert direction for Throughput-mode benchmarks

1 participant