Skip to content
This repository was archived by the owner on Jul 13, 2026. It is now read-only.

Add BenchmarkDotNet project for Files hash APIs - #334

Merged
jonathanpeppers merged 9 commits into
mainfrom
jonathanpeppers/add-files-hash-benchmarks
Apr 23, 2026
Merged

Add BenchmarkDotNet project for Files hash APIs#334
jonathanpeppers merged 9 commits into
mainfrom
jonathanpeppers/add-files-hash-benchmarks

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

The Files class 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.Benchmarks project using BenchmarkDotNet to benchmark the Crc64-based hashing APIs in Files.cs. It also includes a scripts/benchmarks.ps1 script that builds in Release, runs the benchmarks with the GitHub markdown exporter, and writes the results to tests/Xamarin.Android.Tools.Benchmarks/README.md.

What's included:

  • Xamarin.Android.Tools.Benchmarks.csproj -- Exe project targeting net10.0 with BenchmarkDotNet 0.14.0
  • FilesHashBenchmarks.cs -- benchmarks for HashBytes, HashStream, HashFile, and HasFileChanged using 1MB reproducible random data
  • Program.cs -- BenchmarkSwitcher entry point
  • scripts/benchmarks.ps1 -- build + run + export results to README
  • BenchmarkDotNet.Artifacts/ added to .gitignore
  • Project added to Xamarin.Android.Tools.sln

jonathanpeppersand others added 7 commits April 22, 2026 16:28
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>
CopilotAI review requested due to automatic review settings April 22, 2026 21:41

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.Benchmarks BenchmarkDotNet executable project and benchmark suite for Files.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
FileDescription
tests/Xamarin.Android.Tools.Benchmarks/Xamarin.Android.Tools.Benchmarks.csprojNew BenchmarkDotNet executable project referencing Microsoft.Android.Build.BaseTasks.
tests/Xamarin.Android.Tools.Benchmarks/FilesHashBenchmarks.csBenchmarks for HashBytes, HashStream, HashFile, and HasFileChanged using deterministic 1MB data.
tests/Xamarin.Android.Tools.Benchmarks/Program.csBenchmarkDotNet entry point using BenchmarkSwitcher.
tests/Xamarin.Android.Tools.Benchmarks/README.mdCaptured sample benchmark output in GitHub-flavored markdown format.
scripts/benchmarks.ps1Build/run/export automation script for generating the README report.
Xamarin.Android.Tools.slnAdds the new benchmarks project to the solution.
.gitignoreIgnores BenchmarkDotNet.Artifacts/ directories.

Comment threadtests/Xamarin.Android.Tools.Benchmarks/FilesHashBenchmarks.cs Outdated
Comment threadscripts/benchmarks.ps1 Outdated
Comment threadXamarin.Android.Tools.sln
Comment threadtests/Xamarin.Android.Tools.Benchmarks/FilesHashBenchmarks.cs Outdated
Comment threadtests/Xamarin.Android.Tools.Benchmarks/FilesHashBenchmarks.cs Outdated
jonathanpeppersand others added 2 commits April 22, 2026 16:48
- 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>
@jonathanpeppers
jonathanpeppers enabled auto-merge (squash) April 22, 2026 22:09
@jonathanpeppersjonathanpeppers added the ready-to-review This PR is ready to review/merge. label Apr 23, 2026
@jonathanpeppers
jonathanpeppers merged commit 1b2071c into mainApr 23, 2026
2 checks passed
@jonathanpeppers
jonathanpeppers deleted the jonathanpeppers/add-files-hash-benchmarks branch April 23, 2026 14:56
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

ready-to-reviewThis PR is ready to review/merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@jonathanpeppers@simonrozsival