NileshChauhan
NileshChauhan

Reputation: 5559

execution time calculation

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

Are there any industry recognized methods?

Upvotes: 4

Views: 758

Answers (3)

Chris Dunaway
Chris Dunaway

Reputation: 11216

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

Upvotes: 1

Daniel Brückner
Daniel Brückner

Reputation: 59635

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.

Upvotes: 9

Blindy
Blindy

Reputation: 67352

Use the GetTickCount() API function when you enter Main() and again when you're about to exit it, and take the difference between them to get the number of milliseconds your program took.

Upvotes: 0

Related Questions