Skip to content

Commit cbbfe6d

Browse files
authored
chore: add sort logics when print envvars (#3130)
1 parent 438d7bd commit cbbfe6d

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

src/BenchmarkDotNet/Extensions/ProcessExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ internal static void SetEnvironmentVariables(this ProcessStartInfo start, Benchm
112112
SetClrEnvironmentVariables(start, "Version", clrRuntime.Version);
113113

114114
if (benchmarkCase.Job.Environment.Runtime is MonoRuntime monoRuntime && monoRuntime.MonoBclPath.IsNotBlank())
115-
start.EnvironmentVariables["MONO_PATH"] = monoRuntime.MonoBclPath;
115+
start.Environment["MONO_PATH"] = monoRuntime.MonoBclPath;
116116

117117
if (benchmarkCase.Config.HasPerfCollectProfiler())
118118
{
@@ -122,7 +122,7 @@ internal static void SetEnvironmentVariables(this ProcessStartInfo start, Benchm
122122
// enable BDN Event Source (https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/linux-performance-tracing.md#filtering)
123123
SetClrEnvironmentVariables(start, "EventSourceFilter", EngineEventSource.SourceName);
124124
// workaround for https://github.com/dotnet/runtime/issues/71786, will be solved by next perf version
125-
start.EnvironmentVariables["DOTNET_EnableWriteXorExecute"] = "0";
125+
start.Environment["DOTNET_EnableWriteXorExecute"] = "0";
126126
}
127127

128128
// corerun does not understand runtimeconfig.json files;
@@ -132,7 +132,7 @@ internal static void SetEnvironmentVariables(this ProcessStartInfo start, Benchm
132132
start.SetCoreRunEnvironmentVariables(benchmarkCase, resolver);
133133

134134
// disable ReSharper's Dynamic Program Analysis (see https://github.com/dotnet/BenchmarkDotNet/issues/1871 for details)
135-
start.EnvironmentVariables["JETBRAINS_DPA_AGENT_ENABLE"] = "0";
135+
start.Environment["JETBRAINS_DPA_AGENT_ENABLE"] = "0";
136136

137137
if (benchmarkCase.Job.ResolveValueAsNullable(RunMode.RunStrategyCharacteristic) != RunStrategy.ColdStart
138138
// CallCountingDelayMs=0 breaks DisassemblyDiagnoser, so we only set it if the job doesn't need disassembly. https://github.com/dotnet/runtime/issues/117339
@@ -145,7 +145,7 @@ internal static void SetEnvironmentVariables(this ProcessStartInfo start, Benchm
145145
return;
146146

147147
foreach (var environmentVariable in benchmarkCase.Job.Environment.EnvironmentVariables ?? [])
148-
start.EnvironmentVariables[environmentVariable.Key] = environmentVariable.Value;
148+
start.Environment[environmentVariable.Key] = environmentVariable.Value;
149149
}
150150

151151
// the code below was copy-pasted from https://github.com/dotnet/cli/blob/0bc24bff775e22352c2309ef990281280f92dbaa/test/Microsoft.DotNet.Tools.Tests.Utilities/Extensions/ProcessExtensions.cs#L13
@@ -267,8 +267,8 @@ private static void SetCoreRunEnvironmentVariables(this ProcessStartInfo start,
267267

268268
private static void SetClrEnvironmentVariables(ProcessStartInfo start, string suffix, string value)
269269
{
270-
start.EnvironmentVariables[$"DOTNET_{suffix}"] = value;
271-
start.EnvironmentVariables[$"COMPlus_{suffix}"] = value;
270+
start.Environment[$"DOTNET_{suffix}"] = value;
271+
start.Environment[$"COMPlus_{suffix}"] = value;
272272
}
273273

274274
#if !NET5_0_OR_GREATER

src/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliCommandExecutor.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ internal static void LogEnvVars(DotNetCliCommand command)
9494
ProcessStartInfo startInfo = BuildStartInfo(
9595
command.CliPath, command.GenerateResult.ArtifactsPaths.BuildArtifactsDirectoryPath, command.Arguments, command.EnvironmentVariables);
9696

97-
if (startInfo.EnvironmentVariables.Keys.Count > 0)
97+
if (startInfo.Environment.Keys.Count > 0)
9898
{
9999
command.Logger.WriteLineInfo("// Environment Variables:");
100-
foreach (string name in startInfo.EnvironmentVariables.Keys)
100+
foreach (var entry in startInfo.Environment.OrderBy(x=>x.Key))
101101
{
102-
command.Logger.WriteLine($"\t[{name}] = \"{startInfo.EnvironmentVariables[name]}\"");
102+
command.Logger.WriteLine($"\t[{entry.Key}] = \"{entry.Value}\"");
103103
}
104104
}
105105
}
@@ -133,10 +133,10 @@ internal static ProcessStartInfo BuildStartInfo(string? customDotNetCliPath, str
133133

134134
if (environmentVariables != null)
135135
foreach (var environmentVariable in environmentVariables)
136-
startInfo.EnvironmentVariables[environmentVariable.Key] = environmentVariable.Value;
136+
startInfo.Environment[environmentVariable.Key] = environmentVariable.Value;
137137

138138
if (customDotNetCliPath.IsNotBlank() && (environmentVariables == null || environmentVariables.All(envVar => envVar.Key != dotnetMultiLevelLookupEnvVarName)))
139-
startInfo.EnvironmentVariables[dotnetMultiLevelLookupEnvVarName] = "0";
139+
startInfo.Environment[dotnetMultiLevelLookupEnvVarName] = "0";
140140

141141
return startInfo;
142142
}

0 commit comments

Comments
 (0)