how to calculate elapsed time in c for windows

dear expert,

I am trying to calculate how long it takes for my quick sort function to sort an array. I want to calculate it in microseconds because obviously miliseconds and seconds still resulting in 0 elapsed time. I am using microsoft VS . Net 2003. Thank you

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Combines SolarWinds IP Address Manager and User Device Tracker to help detect IP conflicts, quickly identify affected systems, and help your team take near instantaneous action. Help improve visibility and enhance reliability with SolarWinds IP Control Bundle.

Seriously though, if you are testing a sort routine it would be better to call it 1000 times.

Run through one loop, randomising an array of data and then sorting it 1000 times. Then perform another loop just randomising the data. Subtract one from the other. You'll get a much better idea of its performance across a range of data.

Paul

ronald_pangestuAuthor Commented: 2006-04-18

Acctually i only want to run it once. Can you like take a time (in microseconds format) in the beginning of your sort and at the end of your sort or any processing? and at the end you get the difference between those two.

Hi,
Paul is right. Just call your routine 1000 or why not 1000000 times. And simply divide the result to 1000 (or 1000000) at the end. You will get a much better precision for your routine in this way.