Runtime calculation

How to calculate the runtime of your C #, Windows application.

Are there well-known methods?

+4
source share
3 answers

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

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

Use System . Diagnostics StopWatch for profiling isolated tasks.

For advanced tasks you can use System . Diagnostics PerformanceCounter .

+9
source

You may also be interested in PostSharp ( http://www.postsharp.org/ ). You can start it when any method starts or stops.

+1
source

Use the GetTickCount () API function when entering Main () and again when you are about to exit it, and get the difference between them to get the number of milliseconds your program has done.

0
source

All Articles