Skip to content

Add BenchmarkDotNet project for Files hash APIs#334

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

Add BenchmarkDotNet project for Files hash APIs#334
jonathanpeppers merged 9 commits intomainfrom
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

jonathanpeppers and 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>
Copilot AI review requested due to automatic review settings April 22, 2026 21:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
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.

Comment thread tests/Xamarin.Android.Tools.Benchmarks/FilesHashBenchmarks.cs Outdated
Comment thread scripts/benchmarks.ps1 Outdated
Comment thread Xamarin.Android.Tools.sln
Comment thread tests/Xamarin.Android.Tools.Benchmarks/Xamarin.Android.Tools.Benchmarks.csproj Outdated
Comment thread tests/Xamarin.Android.Tools.Benchmarks/FilesHashBenchmarks.cs Outdated
Comment thread tests/Xamarin.Android.Tools.Benchmarks/FilesHashBenchmarks.cs Outdated
jonathanpeppers and 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
@jonathanpeppers jonathanpeppers added the ready-to-review This PR is ready to review/merge. label Apr 23, 2026
@jonathanpeppers jonathanpeppers merged commit 1b2071c into main Apr 23, 2026
2 checks passed
@jonathanpeppers jonathanpeppers deleted the jonathanpeppers/add-files-hash-benchmarks branch April 23, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants