execution time calculation

前端 未结 3 1355
死守一世寂寞
死守一世寂寞 2021-01-06 06:41

How to you calculate Execution time of your C#, Windows Application.

Are there any industry recognized methods?

3条回答
  •  悲&欢浪女
    2021-01-06 07:28

    System.Diagnostics.Process.GetCurrentProcess().TotalProcessorTime - the processor time used by the process (user mode and kernel mode). Use UserProcessorTime and PrivilegedProcessorTime for separate values.

    System.Diagnostics.Process.GetCurrentProcess().StartTime - yields in combination with DateTime.Now the running time of the process.

    Use System.Diagnostics.StopWatch to profile isolated tasks.

    For advanced tasks you can use System.Diagnostics.PerformanceCounter.

提交回复
热议问题