Skip to content

Commit

Permalink
revert last commit change (run global setup regardless of Jitting)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamsitnik authored and alinasmirnova committed Sep 22, 2018
1 parent 06b30fe commit eab4a33
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
5 changes: 0 additions & 5 deletions src/BenchmarkDotNet.Core/Engines/Engine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,13 @@ public void PreAllocate()

public void Jitting()
{
GlobalSetupAction?.Invoke();
IterationSetupAction?.Invoke();

// first signal about jitting is raised from auto-generated Program.cs, look at BenchmarkProgram.txt
Dummy1Action.Invoke();
MainAction.Invoke(1);
Dummy2Action.Invoke();
IdleAction.Invoke(1);
Dummy3Action.Invoke();
isJitted = true;

IterationCleanupAction?.Invoke();
}

public RunResults Run()
Expand Down
5 changes: 5 additions & 0 deletions src/BenchmarkDotNet.Core/Templates/BenchmarkProgram.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,14 @@ namespace BenchmarkDotNet.Autogenerated

engine.PreAllocate();

instance?.globalSetupAction();
instance?.iterationSetupAction();

if (job.ResolveValue(RunMode.RunStrategyCharacteristic, EngineResolver.Instance).NeedsJitting())
engine.Jitting(); // does first call to main action, must be executed after globalSetup() and iterationSetup()!

instance?.iterationCleanupAction();

var results = engine.Run();

instance?.globalCleanupAction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,17 @@ internal static string GetDotNetSdkVersion()
}
}

internal static ProcessStartInfo BuildStartInfo(string customDotNetCliPath, string workingDirectory, string arguments)
{
return new ProcessStartInfo
internal static ProcessStartInfo BuildStartInfo(string customDotNetCliPath, string workingDirectory, string arguments, bool redirectStandardInput = false)
=> new ProcessStartInfo
{
FileName = customDotNetCliPath ?? "dotnet",
WorkingDirectory = workingDirectory,
Arguments = arguments,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true
RedirectStandardError = true,
RedirectStandardInput = redirectStandardInput
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ private ExecuteResult Execute(Benchmark benchmark, ILogger logger, ArtifactsPath
var startInfo = DotNetCliCommandExecutor.BuildStartInfo(
CustomDotNetCliPath,
artifactsPaths.BinariesDirectoryPath,
BuildArgs(diagnoser, executableName));
BuildArgs(diagnoser, executableName),
redirectStandardInput: true);

startInfo.SetEnvironmentVariables(benchmark, resolver);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,14 @@ public static void RunCore(IHost host, Benchmark benchmark, BenchmarkActionCodeg

engine.PreAllocate();

globalSetupAction.InvokeSingle();
iterationSetupAction.InvokeSingle();

if (job.ResolveValue(RunMode.RunStrategyCharacteristic, EngineResolver.Instance).NeedsJitting())
engine.Jitting(); // does first call to main action, must be executed after setup()!

iterationCleanupAction.InvokeSingle();

var results = engine.Run();

globalCleanupAction.InvokeSingle();
Expand Down

0 comments on commit eab4a33

Please sign in to comment.