What's the best way to benchmark programs in Windows?

后端 未结 6 1704
我寻月下人不归
我寻月下人不归 2020-12-09 06:54

I need to do some performance benchmarks on .NET programs (C#) in Windows, but I haven\'t done benchmarking much in the Windows world. I\'ve looked into using the Windows 2

6条回答
  •  爱一瞬间的悲伤
    2020-12-09 07:14

    using System.Diagnostics;
    ....
    
    Stopwatch sw = new Stopwatch();
    
    sw.Start();
    
    // Code you want to time...
    
    // Note: for averaged accuracy (without other OS effects), 
    //       run timed code multiple times in a loop 
    //       and then divide by the number of runs.
    
    sw.Stop();
    
    Console.WriteLine("Took " + sw.ElapsedTicks + " Ticks");
    

提交回复
热议问题