Skip to content

Comments

build: Add generated code performance benchmarks#55

Merged
DrBarnabus merged 1 commit intomainfrom
build/add-generated-code-benchmarks
Feb 22, 2026
Merged

build: Add generated code performance benchmarks#55
DrBarnabus merged 1 commit intomainfrom
build/add-generated-code-benchmarks

Conversation

@DrBarnabus
Copy link
Owner

@DrBarnabus DrBarnabus commented Feb 22, 2026

Summary

  • Add CompositeKey.Benchmarks console project (net8.0/net9.0/net10.0) with BenchmarkDotNet 0.15.8
  • Define five representative key types covering all major code-generation paths: exact-length string.Create, interpolation formatting, DefaultInterpolatedStringHandler with repeating sections, fast-path enum helpers, partition/sort splitting, same-separator repeating, ImmutableArray collection construction, and SpanParsable item parsing
  • Benchmark ToString, Parse, TryParse, ToPartitionKeyString, and ToSortKeyString with [MemoryDiagnoser] tracking throughput, allocations, and GC collections
  • Add BenchmarkDotNet.Artifacts/ to .gitignore, benchmarks README, and CLAUDE.md section

Test plan

  • Solution builds with zero warnings and zero errors
  • All existing tests pass (2,830 across 4 test projects × 3 TFMs)
  • All 17 benchmarks execute successfully via dotnet run -c Release --project src/CompositeKey.Benchmarks -- --filter "*" --job short

Closes #40

Summary by CodeRabbit

Release Notes

  • New Features

    • Added comprehensive benchmarking infrastructure including performance measurement suites for multiple composite key types.
  • Documentation

    • Added benchmark documentation with usage instructions and running guidelines.
  • Chores

    • Updated project configuration files and source control ignore rules to support the benchmarking framework.

Add BenchmarkDotNet benchmarks for generated CompositeKey code to establish
a performance baseline before structural refactoring begins.

- Create CompositeKey.Benchmarks console project targeting net8.0/net9.0/net10.0
- Add BenchmarkDotNet 0.15.8 to central package management
- Define four representative key types covering all major code-generation paths:
  GuidPrimaryKey (stackalloc split), MixedCompositeKey (string.Create exact length,
  partition/sort), RepeatingCollectionKey (DefaultInterpolatedStringHandler),
  FastPathEnumKey (generated enum helpers)
- Benchmark ToString, Parse, TryParse, ToPartitionKeyString, ToSortKeyString
- Track throughput, heap allocations, and GC collections via MemoryDiagnoser
- Add BenchmarkDotNet.Artifacts/ to .gitignore
- Add benchmarks README with run instructions and result interpretation guide
@coderabbitai
Copy link

coderabbitai bot commented Feb 22, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

This pull request introduces a new BenchmarkDotNet-based benchmarking project for CompositeKey, establishing performance baselines across representative key types targeting net8.0, net9.0, and net10.0, with benchmarks for ToString, Parse, and TryParse operations.

Changes

Cohort / File(s) Summary
Project Configuration
.gitignore, CompositeKey.slnx, src/CompositeKey.Benchmarks/CompositeKey.Benchmarks.csproj, src/Directory.Packages.props
Added BenchmarkDotNet artifacts to ignore patterns, registered the new benchmarks project in the solution, configured the benchmark project to target multiple frameworks with BenchmarkDotNet package dependency, and added BenchmarkDotNet 0.15.8 to centralised package versions.
Benchmark Implementations
src/CompositeKey.Benchmarks/FastPathEnumKeyBenchmarks.cs, src/CompositeKey.Benchmarks/GuidPrimaryKeyBenchmarks.cs, src/CompositeKey.Benchmarks/MixedCompositeKeyBenchmarks.cs, src/CompositeKey.Benchmarks/RepeatingCollectionKeyBenchmarks.cs, src/CompositeKey.Benchmarks/RepeatingSpanParsableBenchmarks.cs
Defined five representative composite key types and corresponding benchmark suites, exercising distinct code-generation paths including simple Guid keys, mixed-type keys with partition/sort separation, repeating collection keys, and fast-path enum formatting, each with ToString, Parse, and TryParse benchmarks.
Project Infrastructure
src/CompositeKey.Benchmarks/Program.cs, src/CompositeKey.Benchmarks/packages.lock.json
Added benchmark entry point invoking BenchmarkSwitcher across the assembly, and generated NuGet lockfile specifying dependencies across net8.0, net9.0, and net10.0 frameworks.
Documentation
src/CompositeKey.Benchmarks/README.md, CLAUDE.md
Added benchmark project README detailing execution instructions, filtering, multi-framework targeting, and result interpretation, plus documentation entry in CLAUDE.md.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

enhancement

Poem

🐰 Hop, hop—benchmarks bound,
Stack-alloc'd splits, no heaps around,
Guid and enum paths we trace,
Performance baselines set in place!
Before refactor's gentle paw,
We measure twice to find no flaw.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 and concisely describes the main change: adding performance benchmarks for generated code to the build system.
Linked Issues check ✅ Passed All coding requirements from issue #40 are met: benchmarks project created targeting net8.0/9.0/10.0, BenchmarkDotNet added to Directory.Packages.props, five representative key types defined covering all major generation paths, ToString/Parse/TryParse/partition/sort methods benchmarked with MemoryDiagnoser, README provided, and .gitignore updated.
Out of Scope Changes check ✅ Passed All changes directly support the benchmarks implementation: .gitignore addition, CLAUDE.md documentation, solution file updates, benchmark project structure, representative key types, BenchmarkDotNet package configuration, and supporting files. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch build/add-generated-code-benchmarks

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 and usage tips.

@codecov
Copy link

codecov bot commented Feb 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.66%. Comparing base (d922876) to head (f8ddd13).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #55   +/-   ##
=======================================
  Coverage   87.66%   87.66%           
=======================================
  Files          35       35           
  Lines        2099     2099           
  Branches      344      344           
=======================================
  Hits         1840     1840           
  Misses        157      157           
  Partials      102      102           

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

@DrBarnabus DrBarnabus merged commit d43999a into main Feb 22, 2026
4 checks passed
@DrBarnabus DrBarnabus deleted the build/add-generated-code-benchmarks branch February 22, 2026 21:39
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.

refactor: Add generated code performance benchmarks

1 participant