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
10 changes: 7 additions & 3 deletions src/BenchmarkDotNet/Attributes/Jobs/InProcessAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ public class InProcessAttribute(
bool executeOnSeparateThread = true)
: JobConfigBaseAttribute(GetJob(toolchainType, executeOnSeparateThread))
{
internal static Job GetJob(InProcessToolchainType toolchainType, bool executeOnSeparateThread)
private static Job GetJob(InProcessToolchainType toolchainType, bool executeOnSeparateThread)
=> GetJob(Job.Default, toolchainType, executeOnSeparateThread);

internal static Job GetJob(Job baseJob, InProcessToolchainType toolchainType, bool executeOnSeparateThread)
{
if (toolchainType == InProcessToolchainType.Auto)
{
toolchainType = RuntimeInformation.IsAot
? InProcessToolchainType.NoEmit
: InProcessToolchainType.Emit;
}

return toolchainType == InProcessToolchainType.Emit
? Job.Default.WithToolchain(new InProcessEmitToolchain(new() { ExecuteOnSeparateThread = executeOnSeparateThread }))
: Job.Default.WithToolchain(new InProcessNoEmitToolchain(new() { ExecuteOnSeparateThread = executeOnSeparateThread }));
? baseJob.WithToolchain(new InProcessEmitToolchain(new() { ExecuteOnSeparateThread = executeOnSeparateThread }))
: baseJob.WithToolchain(new InProcessNoEmitToolchain(new() { ExecuteOnSeparateThread = executeOnSeparateThread }));
}
}
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ private static IEnumerable<Job> Expand(Job baseJob, CommandLineOptions options,
{
if (options.RunInProcess)
{
yield return Attributes.InProcessAttribute.GetJob(Attributes.InProcessToolchainType.Auto, true);
yield return Attributes.InProcessAttribute.GetJob(baseJob, Attributes.InProcessToolchainType.Auto, true);
}
else if (options.ClrVersion.IsNotBlank())
{
Expand Down
19 changes: 15 additions & 4 deletions tests/BenchmarkDotNet.Tests/ConfigParserTests.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using System;
using System.Globalization;
using System.IO;
using System.IO;
using System.Linq;
using System.Reflection;
using AwesomeAssertions;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.ConsoleArguments;
Expand All @@ -20,7 +19,7 @@
using BenchmarkDotNet.Toolchains.CoreRun;
using BenchmarkDotNet.Toolchains.CsProj;
using BenchmarkDotNet.Toolchains.DotNetCli;
using BenchmarkDotNet.Toolchains.MonoWasm;
using BenchmarkDotNet.Toolchains.InProcess.Emit;
using BenchmarkDotNet.Toolchains.NativeAot;
using Perfolizer.Horology;
using Xunit;
Expand Down Expand Up @@ -115,6 +114,18 @@ public void UserCanChooseStrategy()
Assert.Equal(RunStrategy.ColdStart, job.Run.RunStrategy);
}

[Fact]
public void UserCanChooseInProcessAndStrategyMonitoring()
{
var configEasy = ConfigParser.Parse(["--inProcess", "--strategy", "Monitoring"], new OutputLogger(Output)).config;

Assert.NotNull(configEasy);
var job = configEasy.GetJobs().Single();

job.GetToolchain().Should().BeOfType<InProcessEmitToolchain>();
job.Run.RunStrategy.Should().Be(RunStrategy.Monitoring);
}

[FactEnvSpecific(
"When CommandLineParser wants to display help, it tries to get the Title of the Entry Assembly which is an xunit runner, which has no Title and fails..",
EnvRequirement.DotNetCoreOnly)]
Expand Down