Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
using BenchmarkDotNet.Running;
using System.Collections.Immutable;

BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args, RecommendedConfig.Create(
// Use RunAsync (not Run) so BDN does not install its single-threaded
// BenchmarkDotNetSynchronizationContext on the entrypoint thread.
await BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).RunAsync(args, RecommendedConfig.Create(
artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location)!, "BenchmarkDotNet.Artifacts")),
mandatoryCategories: ImmutableHashSet.Create(Categories.AkadeIndexedSet)));
mandatoryCategories: ImmutableHashSet.Create(Categories.AkadeIndexedSet)))
.ConfigureAwait(false);
12 changes: 8 additions & 4 deletions src/benchmarks/real-world/ILLink/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Immutable;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using BenchmarkDotNet.Engines;
using BenchmarkDotNet.Extensions;
using BenchmarkDotNet.Jobs;
Expand All @@ -13,7 +14,9 @@ namespace ILLinkBenchmarks;

public class ILLinkBench
{
public static int Main(string[] args)
// Use RunAsync (not Run) so BDN does not install its single-threaded
// BenchmarkDotNetSynchronizationContext on the entrypoint thread.
public static async Task<int> Main(string[] args)
{
string thisAssembly = Assembly.GetExecutingAssembly().Location;
string sampleProjectFile = Path.Combine(Path.GetDirectoryName(thisAssembly), "SampleProject", "HelloWorld.csproj");
Expand All @@ -29,13 +32,14 @@ public static int Main(string[] args)
.WithStrategy(RunStrategy.Monitoring)
.WithMaxRelativeError(0.01);

return BenchmarkSwitcher
var summaries = await BenchmarkSwitcher
.FromAssembly(typeof(BasicBenchmark).Assembly)
.Run(args, RecommendedConfig.Create(
.RunAsync(args, RecommendedConfig.Create(
artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(BasicBenchmark).Assembly.Location),
"BenchmarkDotNet.Artifacts")),
mandatoryCategories: ImmutableHashSet.Create("ILLink"),
job: job))
.ToExitCode();
.ConfigureAwait(false);
return summaries.ToExitCode();
}
}
17 changes: 12 additions & 5 deletions src/benchmarks/real-world/ImageSharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using BenchmarkDotNet.Running;
using System.Collections.Immutable;
using System.IO;
using System.Threading.Tasks;

namespace SixLabors.ImageSharp.Benchmarks
{
Expand All @@ -16,10 +17,16 @@ public class Program
/// <param name="args">
/// The arguments to pass to the program.
/// </param>
public static void Main(string[] args) => BenchmarkSwitcher
.FromAssembly(typeof(Program).Assembly)
.Run(args, RecommendedConfig.Create(
artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "BenchmarkDotNet.Artifacts")),
mandatoryCategories: ImmutableHashSet.Create(Categories.ImageSharp)));
// Use RunAsync (not Run) so BDN does not install its single-threaded
// BenchmarkDotNetSynchronizationContext on the entrypoint thread.
public static async Task Main(string[] args)
{
await BenchmarkSwitcher
.FromAssembly(typeof(Program).Assembly)
.RunAsync(args, RecommendedConfig.Create(
artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "BenchmarkDotNet.Artifacts")),
mandatoryCategories: ImmutableHashSet.Create(Categories.ImageSharp)))
.ConfigureAwait(false);
}
}
}
16 changes: 11 additions & 5 deletions src/benchmarks/real-world/Microsoft.ML.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Globalization;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Extensions;

Expand All @@ -17,13 +18,18 @@ class Program
/// execute dotnet run -c Release and choose the benchmarks you want to run
/// </summary>
/// <param name="args"></param>
static int Main(string[] args)
=> BenchmarkSwitcher
// Use RunAsync (not Run) so BDN does not install its single-threaded
// BenchmarkDotNetSynchronizationContext on the entrypoint thread.
static async Task<int> Main(string[] args)
{
var summaries = await BenchmarkSwitcher
.FromAssembly(typeof(Program).Assembly)
.Run(args, RecommendedConfig.Create(
artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "BenchmarkDotNet.Artifacts")),
.RunAsync(args, RecommendedConfig.Create(
artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "BenchmarkDotNet.Artifacts")),
mandatoryCategories: ImmutableHashSet.Create(Categories.MachineLearning)))
.ToExitCode();
.ConfigureAwait(false);
return summaries.ToExitCode();
}

internal static string GetInvariantCultureDataPath(string name)
{
Expand Down
12 changes: 8 additions & 4 deletions src/benchmarks/real-world/PowerShell.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Threading.Tasks;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Extensions;

namespace MicroBenchmarks
{
public sealed class Program
{
public static int Main(string[] args)
// Use RunAsync (not Run) so BDN does not install its single-threaded
// BenchmarkDotNetSynchronizationContext on the entrypoint thread.
public static async Task<int> Main(string[] args)
{
var argsList = new List<string>(args);
int? partitionCount;
Expand All @@ -38,9 +41,9 @@ public static int Main(string[] args)
return 1;
}

return BenchmarkSwitcher
var summaries = await BenchmarkSwitcher
.FromAssembly(typeof(Program).Assembly)
.Run(
.RunAsync(
argsList.ToArray(),
RecommendedConfig.Create(
artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "BenchmarkDotNet.Artifacts")),
Expand All @@ -50,7 +53,8 @@ public static int Main(string[] args)
exclusionFilterValue: exclusionFilterValue,
categoryExclusionFilterValue: categoryExclusionFilterValue,
getDiffableDisasm: getDiffableDisasm))
.ToExitCode();
.ConfigureAwait(false);
return summaries.ToExitCode();
}
}
}
9 changes: 6 additions & 3 deletions src/benchmarks/real-world/Roslyn/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
// to communicate information is pass by environment variable
Environment.SetEnvironmentVariable(Helpers.TestProjectEnvVarName, sourceDir);

return BenchmarkSwitcher
// Use RunAsync (not Run) so BDN does not install its single-threaded
// BenchmarkDotNetSynchronizationContext on the entrypoint thread.
var summaries = await BenchmarkSwitcher
.FromAssembly(typeof(Helpers).Assembly)
.Run(args, RecommendedConfig.Create(
.RunAsync(args, RecommendedConfig.Create(
artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(Helpers).Assembly.Location),
"BenchmarkDotNet.Artifacts")),
mandatoryCategories: ImmutableHashSet.Create("Roslyn"),
job: Job.Default.WithMaxRelativeError(0.01)))
.ToExitCode();
.ConfigureAwait(false);
return summaries.ToExitCode();
13 changes: 9 additions & 4 deletions src/benchmarks/real-world/bepuphysics2/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
using BenchmarkDotNet.Running;
using DemoBenchmarks;
using System.Collections.Immutable;
using System.Threading.Tasks;

public class BepuPhysics2Benchmarks
{
public static void Main(string[] args) =>
BenchmarkSwitcher
// Use RunAsync (not Run) so BDN does not install its single-threaded
// BenchmarkDotNetSynchronizationContext on the entrypoint thread.
public static async Task Main(string[] args)
{
await BenchmarkSwitcher
.FromAssembly(typeof(BepuPhysics2Benchmarks).Assembly)
.Run(args, RecommendedConfig.Create(
.RunAsync(args, RecommendedConfig.Create(
artifactsPath: new DirectoryInfo(Path.Combine(Path.GetDirectoryName(typeof(BepuPhysics2Benchmarks).Assembly.Location), "BenchmarkDotNet.Artifacts")),
mandatoryCategories: ImmutableHashSet.Create(Categories.BepuPhysics)))
.ToExitCode();
.ConfigureAwait(false);
}
}
Loading