Questions tagged «benchmarkdotnet»

1
有什么可以解释这种情况下使用const的开销?
我的头撞在这里的墙上,所以我希望你们中的一些人可以教育我。我当时使用BenchmarkDotNet进行了一些性能基准测试,但遇到了一个奇怪的情况,在该情况下,声明成员似乎const会大大降低性能。 using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Running; using System; namespace PerfTest { [DisassemblyDiagnoser(printAsm: true, printSource: true)] public class Test { private int[] data; private int Threshold = 90; private const int ConstThreshold = 90; [GlobalSetup] public void GlobalSetup() { data = new int[1000]; var random = new Random(42); for (var i = …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.