Skip to content

Add CancellationToken support to synchronous benchmark runner APIs - #3213

Open
Farhaz565 wants to merge 2 commits into
dotnet:masterfrom
Farhaz565:add-cancellationtoken-support
Open

Add CancellationToken support to synchronous benchmark runner APIs#3213
Farhaz565 wants to merge 2 commits into
dotnet:masterfrom
Farhaz565:add-cancellationtoken-support

Conversation

@Farhaz565

Copy link
Copy Markdown

Summary

Adds CancellationToken support to the synchronous BenchmarkRunner and BenchmarkSwitcher APIs.

Changes

  • Add CancellationToken cancellationToken = default to synchronous Run methods.
  • Forward the token to the corresponding async implementations.
  • Add the RunAsync(BenchmarkRunInfo, CancellationToken) overload.

Validation

  • Built successfully.
  • Ran dotnet test tests/BenchmarkDotNet.Tests/BenchmarkDotNet.Tests.csproj successfully.

Comment thread src/BenchmarkDotNet/Running/BenchmarkRunnerDirty.cs Outdated
=> (await RunAsync([benchmarkRunInfo]).ConfigureAwait(false)).Single();
public static async ValueTask<Summary> RunAsync(
BenchmarkRunInfo benchmarkRunInfo,
CancellationToken cancellationToken = default)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good catch. 👍

@Farhaz565

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CancellationToken support on non-async benchmark runner APIs

2 participants