执行时间计算

Nil*_*han 4 c# algorithm

如何计算C#,Windows应用程序的执行时间.

有没有行业认可的方法?

Dan*_*ner 9

System.Diagnostics.Process.GetCurrentProcess().TotalProcessorTime - 进程使用的处理器时间(用户模式和内核模式).使用UserProcessorTimePrivilegedProcessorTime表示单独的值.

System.Diagnostics.Process.GetCurrentProcess().StartTime- 与...结合的产量DateTime.Now过程的运行时间.

使用System.Diagnostics.StopWatch分析孤立的任务.

对于高级任务,您可以使用System.Diagnostics.PerformanceCounter.