Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

execution time calculation

Tags:

c#

algorithm

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

Are there any industry recognized methods?

like image 966
NileshChauhan Avatar asked Dec 29 '22 23:12

NileshChauhan


2 Answers

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.

like image 92
Daniel Brückner Avatar answered Jan 11 '23 23:01

Daniel Brückner


You might also be interested in PostSharp (http://www.postsharp.org/). You can have it run code when any method starts or stops.

like image 36
Chris Dunaway Avatar answered Jan 12 '23 00:01

Chris Dunaway