Help calculating program speed

Started by
0 comments, last by GameDev.net 24 years, 4 months ago
What is a good way to compare the speed of algorithms in c++. For example, a simple line drawing algorithm can be written either in the classic way using y=mx+b to calculate the next point in a line or it can be done using Bresenham's Line algorithm which gets rid of the floating point math needed in the classic aproach. I would like to see which one of these algorithms will draw a line faster. How can I calculate how fast each one of these approches draws the line?

thanks

Advertisement
I think I would time how long time it takes to draw say 100 lines with each algorithm ,calculate the average of that and then do a compare of those.
As a timer you could use the GetTickCount() win32-function. Maybe there is a better way to do the job but this is the one I can think of right now.

/Derwiath

------------------

------------------------------- Derwiath -

This topic is closed to new replies.

Advertisement