Skip to content

test(bench): add criterion benchmarks - #1682

Merged
orhun merged 3 commits into
orhun:mainfrom
KhadeerBasha1232:bench/criterion
Nov 28, 2026
Merged

orhun merged 3 commits into
orhun:mainfrom
KhadeerBasha1232:bench/criterion

Conversation

@KhadeerBasha1232

Copy link
Copy Markdown
Contributor

Description

Adds a reproducible benchmark suite, as proposed in #1338. Run it with:

cargo bench -p git-cliff --bench changelog       # end-to-end, needs git
cargo bench -p git-cliff-core --bench changelog  # processing + rendering only
  • git-cliff/benches/changelog.rs runs git_cliff::run and write_changelog (with the keepachangelog built-in config) against repositories generated at startup with git2: a linear history with a tag every 10 commits, at 10, 50 and 200 tags. Nothing large is committed and the inputs are the same on every machine.
  • git-cliff-core/benches/changelog.rs covers Changelog::new (conventional parsing, commit parsers, link parsers) for 10/100/1000 releases, and rendering 100 releases with the keepachangelog, detailed and scoped templates. It doesn't touch git.

New dev-dependencies: criterion 0.8 (default features off, so no rayon or plotters), plus git2 in the CLI crate (already a dependency of the core crate, same version).

--bench changelog is needed because a plain cargo bench -p ... also runs the libtest harness of the lib target, which rejects criterion's flags.

Criterion was picked over divan for its --save-baseline / --baseline comparison between main and a feature branch, as discussed in the issue.

Motivation and Context

Closes #1338. The end-to-end bench is shaped to catch regressions like #1668. On a GitHub ubuntu-22.04 runner, main vs. main with #1673 merged:

tags main with #1673 change
10 12.0 ms 8.3 ms -31%
50 132 ms 36 ms -72%
200 1.72 s 0.16 s -91%

How Has This Been Tested?

On a GitHub Actions ubuntu-22.04 runner: cargo +nightly fmt --all -- --check, cargo clippy --tests --benches -- -D warnings, the pedantic clippy command from ci.yml (no warnings in the new files), and both benches.

Not wired into CI in this PR. Happy to add an informational job if you'd like.

Performance

Only adds dev-dependencies and bench targets, so the built git-cliff binary and library are unchanged.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (no code change)
  • Refactor (refactoring production code)
  • Other

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly (if applicable).
  • I have formatted the code with rustfmt.
    • cargo +nightly fmt --all
  • I checked the lints with clippy.
    • cargo clippy --tests --verbose -- -D warnings
  • I have added tests to cover my changes.
  • All new and existing tests passed.
    • cargo test

Add a reproducible benchmark suite:

- git-cliff: end-to-end changelog generation against repositories
  generated at startup (linear history, a tag every 10 commits) with
  10, 50 and 200 tags.
- git-cliff-core: commit processing for 10/100/1000 releases and
  rendering with the built-in templates, without touching git.

Run with `cargo bench -p <crate> --bench changelog`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.97%. Comparing base (87a1e9a) to head (71a71f5).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1682      +/-   ##
==========================================
- Coverage   54.00%   53.97%   -0.03%     
==========================================
  Files          29       29              
  Lines        2676     2676              
==========================================
- Hits         1445     1444       -1     
- Misses       1231     1232       +1     
Flag Coverage Δ
unit-tests 53.97% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@orhun orhun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx!

@orhun
orhun merged commit b902163 into orhun:main Nov 28, 2026
116 of 117 checks passed
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.

Tracking: add performance benchmarks for git-cliff

3 participants