-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add QRCode renderer benchmark; add menu system to benchmarks #659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughRenames several benchmark classes, adds a QRCodeRendererBenchmark with multiple render benchmarks, updates Program to use BenchmarkSwitcher with command-line args, changes project TFM to Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User as CLI User
participant Program as Program.Main
participant Switcher as BenchmarkSwitcher
participant BDN as BenchmarkDotNet
participant Benches as Benchmarks (Assembly)
User->>Program: run with args
Program->>Switcher: FromAssembly(GetExecutingAssembly)
Program->>Switcher: Run(args)
Switcher->>BDN: select & invoke benchmarks
BDN->>Benches: execute selected benchmarks
Benches-->>BDN: results
BDN-->>User: reports/output
sequenceDiagram
autonumber
participant Bench as QRCodeRendererBenchmark
participant Gen as QRCodeGenerator
participant Data as QRCodeData (precomputed)
participant QR as QRCode
participant Renderer as Bitmap renderer
Note over Bench: Constructor precomputes samples
Bench->>Gen: create samples (small/medium/big)
Gen-->>Bench: QRCodeData stored
Note over Bench: Render methods (Small/Medium/Big/Huge)
Bench->>Data: retrieve sample
Bench->>QR: using var qr = new QRCode(data)
QR->>Renderer: GetGraphic(scale)
Renderer-->>Bench: Bitmap (disposed)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (1)
QRCoderBenchmarks/Program.cs (1)
1-4: LGTM!The switch to
BenchmarkSwitcherenables command-line driven benchmark selection, as discussed in previous review comments.
🧹 Nitpick comments (1)
QRCoderBenchmarks/QRCodeRendererBenchmark.cs (1)
12-21: Consider extracting shared sample initialization.The constructor initializes the same samples as
BitmapByteQRCodeRendererBenchmarkandPngByteQRCodeRendererBenchmark. Consider extracting this to a shared base class or helper to reduce duplication.Example approach:
public abstract class QRCodeRendererBenchmarkBase { protected readonly Dictionary<string, QRCodeData> _samples; protected QRCodeRendererBenchmarkBase() { var eccLvl = QRCoder.QRCodeGenerator.ECCLevel.L; _samples = new Dictionary<string, QRCodeData>() { { "small", QRCoder.QRCodeGenerator.GenerateQrCode("ABCD", eccLvl) }, { "medium", QRCoder.QRCodeGenerator.GenerateQrCode("https://github.com/Shane32/QRCoder/blob/f89aa90081f369983a9ba114e49cc6ebf0b2a7b1/QRCoder/Framework4.0Methods/Stream4Methods.cs", eccLvl) }, { "big", QRCoder.QRCodeGenerator.GenerateQrCode(new string('a', 2600), eccLvl) } }; } }Then each benchmark class inherits from this base.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
.gitignore(1 hunks)QRCoderBenchmarks/BitmapByteQRCodeRendererBenchmark.cs(1 hunks)QRCoderBenchmarks/PngByteQRCodeRendererBenchmark.cs(1 hunks)QRCoderBenchmarks/Program.cs(1 hunks)QRCoderBenchmarks/QRCodeGeneratorBenchmark.cs(1 hunks)QRCoderBenchmarks/QRCodeRendererBenchmark.cs(1 hunks)QRCoderBenchmarks/QRCoderBenchmarks.csproj(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
QRCoderBenchmarks/QRCodeRendererBenchmark.cs (3)
QRCoderBenchmarks/BitmapByteQRCodeRendererBenchmark.cs (5)
MemoryDiagnoser(6-50)Benchmark(23-28)Benchmark(30-35)Benchmark(37-42)Benchmark(44-49)QRCoderBenchmarks/PngByteQRCodeRendererBenchmark.cs (5)
MemoryDiagnoser(6-50)Benchmark(23-28)Benchmark(30-35)Benchmark(37-42)Benchmark(44-49)QRCoderBenchmarks/QRCodeGeneratorBenchmark.cs (4)
MemoryDiagnoser(5-31)Benchmark(8-14)Benchmark(16-22)Benchmark(24-30)
🪛 GitHub Actions: Format (Pull Request)
QRCoderBenchmarks/QRCoderBenchmarks.csproj
[error] 1-1: Required references did not load for QRCoder(netstandard1.3) or referenced project. Run dotnet restore prior to formatting.
QRCoderBenchmarks/QRCodeRendererBenchmark.cs
[error] 1-1: IMPORTS: Fix imports ordering.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Test .NET 6.0 Windows
- GitHub Check: Test .NET Core 3.1
- GitHub Check: Test .NET Core 2.1
- GitHub Check: Test .NET 5.0 Windows
- GitHub Check: additional-tests
🔇 Additional comments (6)
QRCoderBenchmarks/QRCoderBenchmarks.csproj (1)
5-5: Appropriate framework change for Windows-specific APIs.The change to
net8.0-windowsis correct sinceQRCodeRendererBenchmark.csusesSystem.Drawing, which requires Windows. The pipeline failure aboutdotnet restoreappears to be an environmental issue rather than a problem with this framework change..gitignore (1)
226-228: LGTM!Standard ignore pattern for BenchmarkDotNet artifacts with a clear comment.
QRCoderBenchmarks/QRCodeGeneratorBenchmark.cs (1)
6-6: LGTM!The rename to
QRCodeGeneratorBenchmarkappropriately distinguishes this benchmark class from the actualQRCoder.QRCodeGeneratorclass being tested.QRCoderBenchmarks/PngByteQRCodeRendererBenchmark.cs (1)
7-11: LGTM!The class and constructor rename to include "Renderer" is consistent with the naming pattern used in
BitmapByteQRCodeRendererBenchmark.QRCoderBenchmarks/BitmapByteQRCodeRendererBenchmark.cs (1)
7-11: LGTM!The rename clarifies that this benchmark focuses on the BitmapByte renderer implementation.
QRCoderBenchmarks/QRCodeRendererBenchmark.cs (1)
23-49: LGTM!The benchmark methods appropriately test QR code rendering at different sizes and scales, correctly disposing of bitmaps via
usingstatements.
Summary by CodeRabbit
New Features
Refactor
Chores