Eric Maino

System.Brain.CoreDump();

Calculating Execution Times

I am currently in the process of creating a class for determining execution times of various programs for my data structures and algorithms course. I have been looking around and have found some alright classes but nothing that appears to be really what I want. I have been looking into the framework, trying to determine the best way to measure an execution time and so far, DateTime.Now.Ticks, I think would be the best choice (Please advise if their is a better choice). This class currently allows for laps (so that multiple executions can be run and compared), and it gives avearge, minimum, and maximum execution times.

Any feedback would be greatly appreciated.

Comments

Nicko said:

You should really use a High Resolution Performance Timer rather than DateTime.Now.

See:
http://codeproject.com/vb/net/vbnetstopwatch.asp
http://www.codeproject.com/useritems/highperformancetimercshar.asp

for sample code
# September 21, 2003 9:40 AM

Scott Watermasysk said:

I am a big fan of the Mentalis StopWatch class:

The .NET framework provides several ways to measure time intervals; you can use the DateTime.Now property or the Environment.TickCount property. However, these methods are not very precise. In fact, the Environment.TickCount can have a worst case resolution of 500 milliseconds. If you need to measure short time intervals, these methods may not be good options.[http://www.mentalis.org/soft/class.qpx?id=8]

# September 21, 2003 10:34 AM

denny said:

you may also want to take alook at the code profiling stuff at msdn ...
there is an episode of msdn tv that talks about it and has links from that video --
linked to the papers is a download of a CLR profiler with full source.
# September 21, 2003 10:55 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)