-
-
Notifications
You must be signed in to change notification settings - Fork 983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented power-management, add docs (#68) #952
Conversation
@MarekM25 thanks for the PR. |
docs/articles/configs/powerplans.md
Outdated
|
||
# Power Plans | ||
|
||
This description concerns only version v0.11.2 and above of BenchmarkDotNet. In the previous versions, benchmarks in the power plans. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need a note about the BenchmarkDotNet version. The documentation is always relevant only for the latest version of BenchmarkDotNet.
namespace BenchmarkDotNet.Samples | ||
{ | ||
[HighPerformancePowerPlan(false)] | ||
public class IntroPowerPlan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the IntroSample, we need two jobs (enabled and disabled high performance power plan) to show the difference between them. An example of the summary table should be included in IntroPowerPlan.md
.
/// determines if BenchmarDotNet changes power plan to High Performance | ||
/// </summary> | ||
[PublicAPI] | ||
public class HighPerformancePowerPlanAttribute : Attribute, IConfigSource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to add [AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
here. It will allow comparing enabled/disabled configurations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be sure I thought about only enabling/disabling the high-performance plan. From my perspective, allowing multiple attributes with the current implementation is not enough (of course, I might be wrong). However, it is a remarkably great idea to do it, and I suggest doing more here. I mean not only analyzing disabled and enabled a high-performance plan but making it possible to compare any power plan for a user. For example, we could compare HighPerformance, Balanced, PowerSaver. What is more, I consider allowing a user to both use power plan enum and provide it by GUID string. The first way contains popular power plan GUIDs such as I mentioned previously. The second approach is essential because companies could have own, custom power plans for any device. This feature allows targeting benchmarks when we could expect what power plan is used by an end user. We could benchmark different power plans if we know that our software will be run on a server, a personal laptop or mobile phone. I could do it willingly as my next issue or by continuing actual:) What do you think?
internal class PowerManagementApplier | ||
{ | ||
private Guid? _userCurrentPowerPlan; | ||
private bool _powerPlanChanged = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use underscores as private field prefixes. Please, remove it.
[Fact] | ||
public void TestSettingAndRevertingBackGuid() | ||
{ | ||
if (RuntimeInformation.IsWindows()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, use FactWindowsOnlyAttribute
instead of such checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx, this is exactly what I needed ! :)
{ | ||
if (RuntimeInformation.IsWindows()) | ||
{ | ||
if (highPerformancePowerPlan && _powerPlanChanged == false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we move the Apply logic from constructor to a separate method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you tell me what do you mean by that? It is not the constructor but a method. Perhaps, I don't understand you. However, I moved logger injection to the constructor.
# Conflicts: # src/BenchmarkDotNet/Configs/ManualConfig.cs
And thanks for your review! :) Could you look why my build fail? Perhaps, we should retry it. I couldn't find that option was available for me. |
@MarekM25 the build is restarted.
It looks pretty interesting. However, let's do the minimal implementation first. Currently, [HighPerformancePowerPlan(false)]
public class IntroPowerPlanDisabled
{
[Benchmark]
public int SplitJoin()
=> string.Join(",", new string[1000]).Split(',').Length;
}
// By default benchmark.net uses high-performance power plan.
// There is no need to set it to true explicitly
[HighPerformancePowerPlan(true)]
public class IntroPowerPlanEnabled
{
[Benchmark]
public int SplitJoin()
=> string.Join(",", new string[1000]).Split(',').Length;
} The PowerPlan should be a property of a job (like |
9623f14
to
684e99d
Compare
Cosmetic fixes (dotnet#68)
4a9e823
to
f3a51c2
Compare
Hi @AndreyAkinshin , |
@MarekM25 I will review this PR on the next week. Meanwhile, could you please resolve conflicts with the master branch? |
# Conflicts: # src/BenchmarkDotNet/Configs/ConfigExtensions.cs
Thx, done ;) @AndreyAkinshin could you take a look? :) |
# Conflicts: # src/BenchmarkDotNet/Jobs/EnvironmentMode.cs
@MarekM25 sorry for such a delay, I had to verify this branch on different laptops. It works great! Thanks for your contribution! |
Thx, it was pleasure for me! |
No description provided.