Add BenchmarkDotNet project for Files hash APIs#334
Merged
jonathanpeppers merged 9 commits intomainfrom Apr 23, 2026
Merged
Conversation
Add tests/Xamarin.Android.Tools.Benchmarks with benchmarks for HashBytes, HashStream, HashFile, and HasFileChanged using the existing Crc64-based hashing in Files.cs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Builds in Release, runs BenchmarkDotNet with GitHub markdown exporter, and copies the report to tests/Xamarin.Android.Tools.Benchmarks/README.md. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new BenchmarkDotNet-based benchmark project to measure and track performance of the Microsoft.Android.Build.Tasks.Files hashing APIs used in incremental builds.
Changes:
- Introduces
tests/Xamarin.Android.Tools.BenchmarksBenchmarkDotNet executable project and benchmark suite forFiles.Hash*APIs. - Adds a PowerShell helper script to build, run, and export benchmark results to a markdown report.
- Updates solution and gitignore to include the new benchmark project and artifacts.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Xamarin.Android.Tools.Benchmarks/Xamarin.Android.Tools.Benchmarks.csproj | New BenchmarkDotNet executable project referencing Microsoft.Android.Build.BaseTasks. |
| tests/Xamarin.Android.Tools.Benchmarks/FilesHashBenchmarks.cs | Benchmarks for HashBytes, HashStream, HashFile, and HasFileChanged using deterministic 1MB data. |
| tests/Xamarin.Android.Tools.Benchmarks/Program.cs | BenchmarkDotNet entry point using BenchmarkSwitcher. |
| tests/Xamarin.Android.Tools.Benchmarks/README.md | Captured sample benchmark output in GitHub-flavored markdown format. |
| scripts/benchmarks.ps1 | Build/run/export automation script for generating the README report. |
| Xamarin.Android.Tools.sln | Adds the new benchmarks project to the solution. |
| .gitignore | Ignores BenchmarkDotNet.Artifacts/ directories. |
- Rename fields to underscore prefix convention (_data, _stream, etc.) - Remove extra stream.Position reset (HashStream already does it) - Dispose initial MemoryStream before reassigning in Setup - Sort markdown reports by LastWriteTime in benchmarks.ps1 - Move BenchmarkDotNet version to Directory.Build.targets Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
simonrozsival
approved these changes
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
Filesclass hashing methods (HashBytes,HashStream,HashFile,HasFileChanged) are used heavily during incremental builds, but we have no benchmarks to measure their performance or track regressions.This PR adds a new
tests/Xamarin.Android.Tools.Benchmarksproject using BenchmarkDotNet to benchmark the Crc64-based hashing APIs inFiles.cs. It also includes ascripts/benchmarks.ps1script that builds in Release, runs the benchmarks with the GitHub markdown exporter, and writes the results totests/Xamarin.Android.Tools.Benchmarks/README.md.What's included:
Xamarin.Android.Tools.Benchmarks.csproj-- Exe project targetingnet10.0with BenchmarkDotNet 0.14.0FilesHashBenchmarks.cs-- benchmarks forHashBytes,HashStream,HashFile, andHasFileChangedusing 1MB reproducible random dataProgram.cs--BenchmarkSwitcherentry pointscripts/benchmarks.ps1-- build + run + export results to READMEBenchmarkDotNet.Artifacts/added to.gitignoreXamarin.Android.Tools.sln