diff --git a/src/BenchmarkDotNet/Attributes/Jobs/InProcessAttribute.cs b/src/BenchmarkDotNet/Attributes/Jobs/InProcessAttribute.cs index feac3604f6..13e0185098 100644 --- a/src/BenchmarkDotNet/Attributes/Jobs/InProcessAttribute.cs +++ b/src/BenchmarkDotNet/Attributes/Jobs/InProcessAttribute.cs @@ -19,7 +19,10 @@ 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) { @@ -27,8 +30,9 @@ internal static Job GetJob(InProcessToolchainType toolchainType, bool executeOnS ? 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 })); } } \ No newline at end of file diff --git a/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs b/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs index 172d57a0e0..af03686c99 100644 --- a/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs +++ b/src/BenchmarkDotNet/ConsoleArguments/ConfigParser.cs @@ -469,7 +469,7 @@ private static IEnumerable 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()) { diff --git a/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs b/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs index 51d300b521..8f0fece42f 100644 --- a/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs +++ b/tests/BenchmarkDotNet.Tests/ConfigParserTests.cs @@ -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; @@ -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; @@ -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(); + 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)]