Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/benchmarking-workflow-dotnet-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ Make sure you have the v8 engine installed and in the PATH. Follow the installat

#### Run the benchmarks with the interpreter

`NoWASM` excludes benchmarks that still require WASM-specific support. Async
benchmarks are not excluded solely because they return `Task` or `ValueTask`:
BenchmarkDotNet awaits them by default. The self-contained async benchmarks
in `Perf_AsyncMethods`, `ValueTaskPerfTest`, `MemoryStreamTests`, and
`MemoryStreamChunkedTests` are eligible for WASM runs. Other benchmarks retain
their exclusions until their platform dependencies and runtime behavior are
validated individually.

1. Configure NuGet Feeds to include local packages. Open the `NuGet.config` and modify `packageSources` section

```xml
Expand Down
3 changes: 1 addition & 2 deletions src/benchmarks/micro/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ static async Task<int> Main(string[] args)
exclusionFilterValue: exclusionFilterValue,
categoryExclusionFilterValue: categoryExclusionFilterValue,
getDiffableDisasm: getDiffableDisasm,
msBuildArguments: msBuildArguments)
.AddValidator(new NoWasmValidator(Categories.NoWASM)))
msBuildArguments: msBuildArguments))
.ConfigureAwait(false);

return summaries.ToExitCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public int ReadSpan()
}

[Benchmark]
[BenchmarkCategory(Categories.NoWASM)]
[MemoryRandomization]
public async Task<int> ReadAsyncMemory()
{
Expand Down Expand Up @@ -113,7 +112,6 @@ public void WriteSpan()
}

[Benchmark]
[BenchmarkCategory(Categories.NoWASM)]
[MemoryRandomization]
public async Task WriteAsyncMemory()
{
Expand All @@ -138,7 +136,6 @@ public void CopyToWithBufferSize()
}

[Benchmark]
[BenchmarkCategory(Categories.NoWASM)]
[MemoryRandomization]
public async Task CopyToAsyncWithBufferSize()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public void CopyTo()
}

[Benchmark]
[BenchmarkCategory(Categories.NoWASM)]
[MemoryRandomization]
public async Task CopyToAsync()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace System.Threading.Tasks
{
[BenchmarkCategory(Categories.Libraries, Categories.NoWASM)]
[BenchmarkCategory(Categories.Libraries)]
[MinWarmupCount(2, forceAutoWarmup: true)] // these benchmarks require more warmups than in our default config
[MaxWarmupCount(10, forceAutoWarmup: true)]
public class ValueTaskPerfTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace System.Threading.Tasks.Tests
{
[BenchmarkCategory(Categories.Libraries, Categories.NoWASM)]
[BenchmarkCategory(Categories.Libraries)]
public class Perf_AsyncMethods
{
[Benchmark(OperationsPerInvoke = 100_000)]
Expand Down
47 changes: 0 additions & 47 deletions src/harness/BenchmarkDotNet.Extensions/NoWasmValidator.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.IO.Pipelines.Tests;
using System.IO.Tests;
using System.Linq;
using System.Threading.Tasks;
using System.Threading.Tasks.Tests;
using BenchmarkDotNet.Running;
using MicroBenchmarks;
using Xunit;

namespace Tests
{
public class WasmAsyncBenchmarkSelectionTests
{
[Theory]
[InlineData(typeof(Perf_AsyncMethods), nameof(Perf_AsyncMethods.Yield))]
[InlineData(typeof(ValueTaskPerfTest), nameof(ValueTaskPerfTest.CreateAndAwait_FromYieldingAsyncMethod))]
[InlineData(typeof(MemoryStreamTests), nameof(MemoryStreamTests.CopyToAsync))]
[InlineData(typeof(MemoryStreamChunkedTests), nameof(MemoryStreamChunkedTests.ReadAsyncMemory))]
[InlineData(typeof(MemoryStreamChunkedTests), nameof(MemoryStreamChunkedTests.WriteAsyncMemory))]
[InlineData(typeof(MemoryStreamChunkedTests), nameof(MemoryStreamChunkedTests.CopyToAsyncWithBufferSize))]
public void AsyncBenchmarkIsNotExcludedFromWasm(Type benchmarkType, string methodName)
{
var benchmarks = BenchmarkConverter.TypeToBenchmarks(benchmarkType).BenchmarksCases
.Where(benchmark => benchmark.Descriptor.WorkloadMethod.Name == methodName)
.ToArray();

Assert.NotEmpty(benchmarks);
Assert.All(benchmarks, benchmark => Assert.DoesNotContain(Categories.NoWASM, benchmark.Descriptor.Categories));
}

[Fact]
public void OtherAsyncBenchmarksRemainExcludedFromWasm()
{
var benchmarks = BenchmarkConverter.TypeToBenchmarks(typeof(Perf_Pipe)).BenchmarksCases;

Assert.NotEmpty(benchmarks);
Assert.All(benchmarks, benchmark => Assert.Contains(Categories.NoWASM, benchmark.Descriptor.Categories));
}
}
}
Loading