Nuget: https://www.nuget.org/packages/BenchmarkDotNet/
Project Site: https://github.com/PerfDotNet/BenchmarkDotNet
using BenchmarkDotNet; namespace NumberRollOverTest { public class NumberRollOver { public const byte Max = byte.MaxValue; [Benchmark] public void TestRollOver() { RollOver(Max); } [Benchmark] public void TestRollOverByCast() { RollOverByCast(Max); } ... }
第二步,啟動Benchmark主程序(BenchmarkRunner)
using System; namespace NumberRollOverTest { class Program { static void Main(string[] args) { new BenchmarkDotNet.BenchmarkRunner().RunCompetition(new NumberRollOver()); Console.Read(); } } }