BenchmarkDotNet icon indicating copy to clipboard operation
BenchmarkDotNet copied to clipboard

[Bug] Pointless power plan change

Open levicki opened this issue 2 years ago • 3 comments

You should not change power plant to High Performance if it is already Ultimate Performance.

levicki avatar Jun 05 '23 16:06 levicki

The bug must me somewhere here: https://github.com/dotnet/BenchmarkDotNet/blob/master/src/BenchmarkDotNet/Running/PowerManagementApplier.cs

Please send a PR with a fix

adamsitnik avatar Jun 05 '23 16:06 adamsitnik

From the brief look at it I am not seeing the problem, must be in the calling code.

Another thing, what happens when user presses Ctrl+C to interrupt test execution? I don't see the code hooking console event handler to restore power plan when process is interrupted?

Absolutely the whole idea of messing with user settings is IMO bad if you don't guarantee they will be restored.

Another scenario -- Windows Update decides to restart the PC while the benchmark is running. Are you intercepting WM_QUERYENDSESSION to stop shutdown or at least restore power plan there?

levicki avatar Jun 05 '23 22:06 levicki

Just had to come here and say as someone that just tried this framework the changing of power plans feels very weird. On my laptop I use balanced, yet when running these tests it changes the profile to performance, which increases my screen brightness (I have custom settings I'd like to retain between the different performance profiles). Is there a reason this is done, that performance profiling cannot be done on the user's current power plan?

heron1 avatar Oct 17 '23 09:10 heron1