Precision of clock()

P

Peger, Daniel H.

Hi,
I'm having a slight problem with the precision of the standard c++ clock
function as it is defined in time.h .

On my system the shortest meassurable time period is 0.01 seconds, but for
my programm I need to meassure the processing time in ms.

Is there perhaps something like an environment variable controlling the
precision of clock(), or is there any other way of meassuring time in ANSI
C in the ms domain??

Could running the code on a notebook with speedstep cause problems?? Idle
CPU-Freq is 600MHz and 100% is 1500MHz?

Regards, Daniel.

My code looks like this:

void test() {

for ( int i = 0; i<10000; i++) {

cout << "clock() = " << clock() << "\n";
}
}

and the output:

....
clock() = 190000
clock() = 190000
clock() = 200000
clock() = 200000
clock() = 200000
clock() = 200000
clock() = 200000
clock() = 200000
....
clock() = 210000
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top