BenchmarkDotNet
BenchmarkDotNet copied to clipboard
Better support for asymmetric CPU cores
When running benchmark on my Raptor Lake processor, I find the time of each iteration shifts between two values if I switch the console window to background.
This is probably due to the "smart" scheduling for P/E cores of Windows. I've also heard that thread affinity API getting ignored by the system in some situations.
It would also be interesting to see the results on E-cores. To be more general, there can be a configuration to set thread affinity for benchmarks. This can also help benchmarking for arbitrary core counts.
We already support --affinity
command line arg and Job.WithAffinity
config option. Does that do what you need?
I've also heard that thread affinity API getting ignored by the system in some situations.
If that's true, that would be an issue for runtime or the OS, not BDN.
We already support
--affinity
command line arg andJob.WithAffinity
config option. Does that do what you need?
--affinity 1
and --affinity 65536
give me significant comparison of P/E cores.
Is there more handy way to compare different affinities? Job
is just heavier to use. I can't find affinity setting in attributes.
I don't think there is another built-in way to do it. You could create your own attribute to do it, though.
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = true)]
public class AffinitizedJobAttribute : JobConfigBaseAttribute
{
// Add whatever other settings you need.
public AffinitizedJobAttribute(int affinity) : base(Job.Default.WithAffinity((IntPtr) affinity)) { }
}
I don't think there is anything actionable here, so closing this out. Let me know if you disagree.