Skip to content

Add Android BenchmarkDotNet template#11312

Draft
simonrozsival wants to merge 8 commits into
mainfrom
android-benchmarkdotnet-template
Draft

Add Android BenchmarkDotNet template#11312
simonrozsival wants to merge 8 commits into
mainfrom
android-benchmarkdotnet-template

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

Summary

  • add an android-benchmarkdotnet project template that runs BenchmarkDotNet from an Android instrumentation class on CoreCLR
  • wire dotnet run -- ... argument pass-through for instrumentation runs, including BenchmarkDotNet --filter/--job support in the template
  • parse instrumentation result bundles, report failures, and pull BenchmarkDotNet.Artifacts back to the working directory
  • add MSBuild device integration coverage for template creation/build/run/artifact pull

Validation

  • dotnet build src/Microsoft.Android.Run/Microsoft.Android.Run.csproj -v:minimal
  • dotnet build src/Microsoft.Android.Templates/Microsoft.Android.Templates.csproj -v:minimal
  • dotnet build tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.csproj -v:minimal
  • dotnet build src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj --no-dependencies -v:minimal
  • git diff --check
  • manual Samsung A16 CoreCLR instrumentation run with BenchmarkDotNet artifacts pulled successfully

Note: the new filtered MSBuild device integration test is authored but was not runnable end-to-end in this local worktree because local workload/runtime pack generation is incomplete.

Adds an Android BenchmarkDotNet project template that runs benchmarks through an instrumentation class on CoreCLR. The template uses BenchmarkDotNet's in-process no-emit toolchain and supports dotnet run argument pass-through for common options such as --filter and --job.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival force-pushed the android-benchmarkdotnet-template branch from 8258972 to 9c21329 Compare May 9, 2026 15:31
simonrozsival and others added 6 commits May 9, 2026 17:42
Use a dotnet-run scoped argument bundle key and generic artifact messages in Microsoft.Android.Run. Keep BenchmarkDotNet-specific argument parsing in the Android BenchmarkDotNet template instrumentation class.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Allow the Android BenchmarkDotNet template to select either BenchmarkDotNet in-process toolchain with --toolchain emit|noemit. Keep noemit as the default, and document why Android instrumentation cannot use BenchmarkDotNet's external SDK-based toolchains.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the BenchmarkDotNet package version local to the template, remove the temporary template hive test helper path, and use a single in-process BenchmarkDotNet toolchain default.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Drain instrumentation output before parsing results, fail runs when reported artifacts cannot be pulled, validate device artifact paths before adb pull, and add focused coverage for instrumentation argument forwarding.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Document that the Mono.Options <> handler captures forwarded app arguments after dotnet run --, not the delimiter itself.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread src/Microsoft.Android.Templates/android-benchmarkdotnet/AndroidBenchmark1.csproj Outdated
Comment on lines +49 to +50
[Test]
public void ComputeRunArgumentsForwardsInstrumentationStartArguments ()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is also a test that just verifies every project template builds, we might add this new one to the list.

- AndroidBenchmark1.csproj: replace blanket PublishTrimmed=false/PublishReadyToRun=false
  with TrimmerRootAssembly entries that keep BenchmarkDotNet and the user's own
  assembly intact while letting the rest of the app trim normally.
- Microsoft.Android.Sdk.Application.targets: inline $(StartArguments) directly in
  RunArguments instead of introducing a dedicated _AndroidRunStartArguments
  property. Microsoft.Android.Run only accepts positional arguments in --instrument
  mode and will surface a usage error otherwise.
- XASdkTests: add android-benchmarkdotnet to DotNetNew's [Values] so the new
  template is exercised by the build-every-template fixture, and update
  ComputeRunArgumentsForwardsInstrumentationStartArguments to match the
  simplified targets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants