Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using clock() function......

Status
Not open for further replies.

robbaggio

Programmer
Jun 11, 2002
31
0
0
US
I am trying timestamp a simple insertion sort program that I am writing....but so far I have been unable to get meaningful results. The program does not take very long to run...but using the clock() function I thought that this would still output some values...but I still get zero.

The machine I am on has 1000000 CLOCKS_PER_SEC. Right before I start the sort I call the clock function and save to a clock_t variable. Then at the very end of the program i do the same thing to another clock_t variable. The only problem is that these two values are always the same..which means my program has a runtime of 0 clock ticks? This cant be right.

What am I doing wrong? Or is there another function that would work better for time-stamping (cant use time() cuz i need more precision than just seconds).

Any help would be greatly appreciated.

Thanks

robbaggio
 
The functions
QueryPerformanceCounter() and
QueryPerformanceFrequency()

are excellent for measure of very short time-intervals

/JOlesen
 
sorry....forgot to mention.....im not using Visuall C++...im running my compiler in LINUX....and comparable function in linux?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top