[PR #1111] Add BenchmarkDotNet performance benchmarking infrastructure #1541

Open
opened 2026-01-29 22:21:04 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/adamhathcock/sharpcompress/pull/1111
Author: @Copilot
Created: 1/5/2026
Status: 🔄 Open

Base: masterHead: copilot/add-performance-benchmarking


📝 Commits (8)

  • 6125654 Initial plan
  • aa3a40d Add BenchmarkDotNet integration with Archive and Reader benchmarks
  • 5b1d11b Add WriteBenchmarks, BaselineComparisonBenchmarks, and comprehensive documentation
  • 49f2271 Format code with CSharpier
  • e519f61 Address code review feedback: fix exception handling and initialization order
  • a92ce90 Fix path validation and add iteration cleanup to prevent file reuse
  • 80ac10a Merge latest master branch and resolve conflicts
  • 5c4b83e Merge remote-tracking branch 'origin/master' into copilot/add-performance-benchmarking

📊 Changes

12 files changed (+688 additions, -50 deletions)

View changed files

📝 .gitignore (+4 -0)
📝 Directory.Packages.props (+1 -0)
📝 src/SharpCompress/packages.lock.json (+3 -3)
tests/SharpCompress.Performance/ArchiveReadBenchmarks.cs (+86 -0)
tests/SharpCompress.Performance/BaselineComparisonBenchmarks.cs (+47 -0)
tests/SharpCompress.Performance/BenchmarkBase.cs (+37 -0)
📝 tests/SharpCompress.Performance/Program.cs (+9 -47)
tests/SharpCompress.Performance/README.md (+131 -0)
tests/SharpCompress.Performance/ReaderBenchmarks.cs (+88 -0)
📝 tests/SharpCompress.Performance/SharpCompress.Performance.csproj (+1 -0)
tests/SharpCompress.Performance/WriteBenchmarks.cs (+106 -0)
📝 tests/SharpCompress.Performance/packages.lock.json (+175 -0)

📄 Description

Performance Benchmarks Implementation - Complete

Successfully integrated BenchmarkDotNet into the SharpCompress.Performance project with comprehensive benchmarking capabilities.

Recent Updates

  • Merged latest master branch
  • Resolved merge conflicts in packages.lock.json
  • Verified benchmarks work correctly after merge

Implemented Benchmarks

  1. ArchiveReadBenchmarks - Archive API (random access) for Zip, Tar, Tar.gz, Tar.bz2, 7Zip, Rar
  2. ReaderBenchmarks - Reader API (forward-only streaming) for Zip, Tar, Tar.gz, Tar.bz2, Rar
  3. WriteBenchmarks - Writer API (forward-only writing) for Zip, Tar, Tar.gz
  4. BaselineComparisonBenchmarks - Example showing baseline comparison with ratio calculations

Features

Memory diagnostics with [MemoryDiagnoser] attribute
Baseline comparison support for tracking performance changes
Test archives from existing TestArchives directory
Comprehensive README with usage examples and best practices
BenchmarkDotNet artifacts excluded from git
All code formatted with CSharpier
Proper exception handling with descriptive messages
Path validation to prevent IndexOf returning -1
Iteration cleanup to prevent file reuse affecting measurements
Test files initialized in GlobalSetup to avoid initialization order issues
Compatible with latest master branch changes

Usage Examples

# Run all benchmarks
dotnet run -c Release

# Run specific format
dotnet run -c Release -- --filter "*Zip*"

# Quick test (dry run)
dotnet run -c Release -- --job dry

# List all benchmarks
dotnet run -c Release -- --list tree

Sample Output

Benchmarks provide detailed metrics including:

  • Mean execution time
  • Memory allocation per operation
  • Rank and Ratio columns (when using baseline comparison)
  • Exported reports in CSV, HTML, and Markdown formats

See tests/SharpCompress.Performance/README.md for comprehensive documentation.

Original prompt

This section details on the original issue you should resolve

<issue_title>Performance benchmarks</issue_title>
<issue_description>The performance project should use benchmark.net with some snapshotting to automate benchmarking and ensure there are no major reductions in performance and actual increases can be found.</issue_description>

<agent_instructions>Reuse the Performance project and there should be a number of tests for each format like the archives in the tests. See if Benchmark.NET can compare the current to a previous nuget.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/adamhathcock/sharpcompress/pull/1111 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 1/5/2026 **Status:** 🔄 Open **Base:** `master` ← **Head:** `copilot/add-performance-benchmarking` --- ### 📝 Commits (8) - [`6125654`](https://github.com/adamhathcock/sharpcompress/commit/6125654b2e86ef49452ecedd450d1261c11d1708) Initial plan - [`aa3a40d`](https://github.com/adamhathcock/sharpcompress/commit/aa3a40d968d605f57398be54f0a191cd3883c579) Add BenchmarkDotNet integration with Archive and Reader benchmarks - [`5b1d11b`](https://github.com/adamhathcock/sharpcompress/commit/5b1d11bc1d8f6db3e423aea11709df5a85a8a970) Add WriteBenchmarks, BaselineComparisonBenchmarks, and comprehensive documentation - [`49f2271`](https://github.com/adamhathcock/sharpcompress/commit/49f22712534f6f30172f27f5949817639df39880) Format code with CSharpier - [`e519f61`](https://github.com/adamhathcock/sharpcompress/commit/e519f61f0fabc4cea1c82695cbbe20fbd0b91c3c) Address code review feedback: fix exception handling and initialization order - [`a92ce90`](https://github.com/adamhathcock/sharpcompress/commit/a92ce90252be88fc9f7a79986853bfc147b87d77) Fix path validation and add iteration cleanup to prevent file reuse - [`80ac10a`](https://github.com/adamhathcock/sharpcompress/commit/80ac10a5fecf2d2331959d3ac3142f9074c43d43) Merge latest master branch and resolve conflicts - [`5c4b83e`](https://github.com/adamhathcock/sharpcompress/commit/5c4b83e501c5d29f2429c8ee938c6680ee1bab35) Merge remote-tracking branch 'origin/master' into copilot/add-performance-benchmarking ### 📊 Changes **12 files changed** (+688 additions, -50 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+4 -0) 📝 `Directory.Packages.props` (+1 -0) 📝 `src/SharpCompress/packages.lock.json` (+3 -3) ➕ `tests/SharpCompress.Performance/ArchiveReadBenchmarks.cs` (+86 -0) ➕ `tests/SharpCompress.Performance/BaselineComparisonBenchmarks.cs` (+47 -0) ➕ `tests/SharpCompress.Performance/BenchmarkBase.cs` (+37 -0) 📝 `tests/SharpCompress.Performance/Program.cs` (+9 -47) ➕ `tests/SharpCompress.Performance/README.md` (+131 -0) ➕ `tests/SharpCompress.Performance/ReaderBenchmarks.cs` (+88 -0) 📝 `tests/SharpCompress.Performance/SharpCompress.Performance.csproj` (+1 -0) ➕ `tests/SharpCompress.Performance/WriteBenchmarks.cs` (+106 -0) 📝 `tests/SharpCompress.Performance/packages.lock.json` (+175 -0) </details> ### 📄 Description ## Performance Benchmarks Implementation - Complete ✅ Successfully integrated BenchmarkDotNet into the SharpCompress.Performance project with comprehensive benchmarking capabilities. ### Recent Updates - ✅ Merged latest master branch - ✅ Resolved merge conflicts in packages.lock.json - ✅ Verified benchmarks work correctly after merge ### Implemented Benchmarks 1. **ArchiveReadBenchmarks** - Archive API (random access) for Zip, Tar, Tar.gz, Tar.bz2, 7Zip, Rar 2. **ReaderBenchmarks** - Reader API (forward-only streaming) for Zip, Tar, Tar.gz, Tar.bz2, Rar 3. **WriteBenchmarks** - Writer API (forward-only writing) for Zip, Tar, Tar.gz 4. **BaselineComparisonBenchmarks** - Example showing baseline comparison with ratio calculations ### Features ✅ Memory diagnostics with `[MemoryDiagnoser]` attribute ✅ Baseline comparison support for tracking performance changes ✅ Test archives from existing TestArchives directory ✅ Comprehensive README with usage examples and best practices ✅ BenchmarkDotNet artifacts excluded from git ✅ All code formatted with CSharpier ✅ Proper exception handling with descriptive messages ✅ Path validation to prevent IndexOf returning -1 ✅ Iteration cleanup to prevent file reuse affecting measurements ✅ Test files initialized in GlobalSetup to avoid initialization order issues ✅ Compatible with latest master branch changes ### Usage Examples ```bash # Run all benchmarks dotnet run -c Release # Run specific format dotnet run -c Release -- --filter "*Zip*" # Quick test (dry run) dotnet run -c Release -- --job dry # List all benchmarks dotnet run -c Release -- --list tree ``` ### Sample Output Benchmarks provide detailed metrics including: - Mean execution time - Memory allocation per operation - Rank and Ratio columns (when using baseline comparison) - Exported reports in CSV, HTML, and Markdown formats See `tests/SharpCompress.Performance/README.md` for comprehensive documentation. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Performance benchmarks</issue_title> > <issue_description>The performance project should use benchmark.net with some snapshotting to automate benchmarking and ensure there are no major reductions in performance and actual increases can be found.</issue_description> > > <agent_instructions>Reuse the Performance project and there should be a number of tests for each format like the archives in the tests. See if Benchmark.NET can compare the current to a previous nuget.</agent_instructions> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes adamhathcock/sharpcompress#1107 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 22:21:04 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1541