Skip to content

Commit e62dc27

Browse files
authored
align both Executors to use the same timeout (2s) (#1848)
1 parent dddc1ea commit e62dc27

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliExecutor.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Diagnostics;
33
using System.IO;
4-
using System.Threading;
54
using BenchmarkDotNet.Characteristics;
65
using BenchmarkDotNet.Diagnosers;
76
using BenchmarkDotNet.Engines;
@@ -22,7 +21,6 @@ public class DotNetCliExecutor : IExecutor
2221
public DotNetCliExecutor(string customDotNetCliPath) => CustomDotNetCliPath = customDotNetCliPath;
2322

2423
private string CustomDotNetCliPath { get; }
25-
private static readonly TimeSpan ProcessExitTimeout = TimeSpan.FromSeconds(2);
2624

2725
public ExecuteResult Execute(ExecuteParameters executeParameters)
2826
{
@@ -90,14 +88,14 @@ private ExecuteResult Execute(BenchmarkCase benchmarkCase,
9088

9189
loggerWithDiagnoser.ProcessInput();
9290

93-
if (!process.WaitForExit(milliseconds: (int)ProcessExitTimeout.TotalMilliseconds))
91+
if (!process.WaitForExit(milliseconds: (int)ExecuteParameters.ProcessExitTimeout.TotalMilliseconds))
9492
{
95-
logger.WriteLineInfo($"// The benchmarking process did not quit within {ProcessExitTimeout.TotalSeconds} seconds, it's going to get force killed now.");
93+
logger.WriteLineInfo($"// The benchmarking process did not quit within {ExecuteParameters.ProcessExitTimeout.TotalSeconds} seconds, it's going to get force killed now.");
9694

9795
consoleExitHandler.KillProcessTree();
9896
}
9997

100-
return new ExecuteResult(true, process.HasExited ? (int?)process.ExitCode : null, process.Id, loggerWithDiagnoser.LinesWithResults, loggerWithDiagnoser.LinesWithExtraOutput);
98+
return new ExecuteResult(true, process.HasExited ? process.ExitCode : null, process.Id, loggerWithDiagnoser.LinesWithResults, loggerWithDiagnoser.LinesWithExtraOutput);
10199
}
102100
}
103101
}

src/BenchmarkDotNet/Toolchains/Executor.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using BenchmarkDotNet.Helpers;
1212
using BenchmarkDotNet.Jobs;
1313
using BenchmarkDotNet.Loggers;
14-
using BenchmarkDotNet.Portability;
1514
using BenchmarkDotNet.Running;
1615
using BenchmarkDotNet.Toolchains.Parameters;
1716
using BenchmarkDotNet.Toolchains.Results;
@@ -69,7 +68,7 @@ private ExecuteResult Execute(Process process, BenchmarkCase benchmarkCase, Sync
6968

7069
loggerWithDiagnoser.ProcessInput();
7170

72-
if (!process.WaitForExit(milliseconds: 250))
71+
if (!process.WaitForExit(milliseconds: (int)ExecuteParameters.ProcessExitTimeout.TotalMilliseconds))
7372
{
7473
logger.WriteLineInfo("// The benchmarking process did not quit on time, it's going to get force killed now.");
7574

src/BenchmarkDotNet/Toolchains/Parameters/ExecuteParameters.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
using BenchmarkDotNet.Loggers;
44
using BenchmarkDotNet.Running;
55
using BenchmarkDotNet.Toolchains.Results;
6+
using System;
67

78
namespace BenchmarkDotNet.Toolchains.Parameters
89
{
910
public class ExecuteParameters
1011
{
12+
internal static readonly TimeSpan ProcessExitTimeout = TimeSpan.FromSeconds(2);
13+
1114
public ExecuteParameters(BuildResult buildResult, BenchmarkCase benchmarkCase, BenchmarkId benchmarkId, ILogger logger, IResolver resolver, IDiagnoser diagnoser = null)
1215
{
1316
BuildResult = buildResult;

0 commit comments

Comments
 (0)