Skip to content

Commit 23d1150

Browse files
force High Performance Mode by default, fixes #1506 (#1885)
1 parent f17453c commit 23d1150

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/BenchmarkDotNet/Jobs/EnvironmentMode.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public sealed class EnvironmentMode : JobMode<EnvironmentMode>
1414
public static readonly Characteristic<IntPtr> AffinityCharacteristic = CreateCharacteristic<IntPtr>(nameof(Affinity));
1515
public static readonly Characteristic<GcMode> GcCharacteristic = CreateCharacteristic<GcMode>(nameof(Gc));
1616
public static readonly Characteristic<IReadOnlyList<EnvironmentVariable>> EnvironmentVariablesCharacteristic = CreateCharacteristic<IReadOnlyList<EnvironmentVariable>>(nameof(EnvironmentVariables));
17-
public static readonly Characteristic<Guid> PowerPlanModeCharacteristic = CreateCharacteristic<Guid>(nameof(PowerPlanMode));
17+
public static readonly Characteristic<Guid?> PowerPlanModeCharacteristic = CreateCharacteristic<Guid?>(nameof(PowerPlanMode));
1818

1919
public static readonly EnvironmentMode LegacyJitX86 = new EnvironmentMode(nameof(LegacyJitX86), Jit.LegacyJit, Platform.X86).Freeze();
2020
public static readonly EnvironmentMode LegacyJitX64 = new EnvironmentMode(nameof(LegacyJitX64), Jit.LegacyJit, Platform.X64).Freeze();
@@ -89,7 +89,7 @@ public IReadOnlyList<EnvironmentVariable> EnvironmentVariables
8989
/// Power Plan Mode
9090
/// </summary>
9191
/// <remarks>Supported only on Windows.</remarks>
92-
public Guid PowerPlanMode
92+
public Guid? PowerPlanMode
9393
{
9494
get => PowerPlanModeCharacteristic[this];
9595
set => PowerPlanModeCharacteristic[this] = value;

src/BenchmarkDotNet/Running/BenchmarkRunnerClean.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ private static Summary Run(BenchmarkRunInfo benchmarkRunInfo,
148148
{
149149
foreach (var benchmark in benchmarks)
150150
{
151-
powerManagementApplier.ApplyPerformancePlan(benchmark.Job.Environment.PowerPlanMode);
151+
powerManagementApplier.ApplyPerformancePlan(benchmark.Job.Environment.PowerPlanMode
152+
?? benchmark.Job.ResolveValue(EnvironmentMode.PowerPlanModeCharacteristic, EnvironmentResolver.Instance).GetValueOrDefault());
152153

153154
var info = buildResults[benchmark];
154155
var buildResult = info.buildResult;

src/BenchmarkDotNet/Running/PowerManagementApplier.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal void ApplyPerformancePlan(Guid id)
3636
if (!RuntimeInformation.IsWindows() || id == Guid.Empty)
3737
return;
3838

39-
if (!powerPlanChanged && id != UserPowerPlan)
39+
if (id != UserPowerPlan)
4040
ApplyPlanByGuid(id);
4141
else
4242
ApplyUserPowerPlan();

0 commit comments

Comments
 (0)