GetTickCount question

 

Hi all, I often use the following to check times and efficiency

int timing = GetTickCount();

//lots of stuff here

timing = GetTickCount() - timing;

I get values of 0 or high value but I never seen values 1-14

One part of code fluctuates between 15 and 16 milliseconds but is sometimes 0... I'm wondering is this actually 14 but somehow I'm losing the value? 

The reference says:  "It is limited to the resolution of the system timer." but I'm not sure what this means.

Can I run the code section in a for loop 100 times, divide the answer by 100 and get reliable results? 

 

 
alladir:

Hi all, I often use the following to check times and efficiency

I get values of 0 or high value but I never seen values 1-14

One part of code fluctuates between 15 and 16 milliseconds but is sometimes 0... I'm wondering is this actually 14 but somehow I'm losing the value? 

The reference says:  "It is limited to the resolution of the system timer." but I'm not sure what this means.

Can I run the code section in a for loop 100 times, divide the answer by 100 and get reliable results? 

 

You should do exactly that but with a greater loop count,  try 10,000 or 100,000 or 1,000,000  You shouldn't worry about absolute results you should be looking for comparative relative results.  If you are trying to time placing of Orders this is a different story,  you can't send 10,000 orders . . .

The system time is your PC clock, it determines the accuracy of the timings. 

 
alladir:

Hi all, I often use the following to check times and efficiency

I get values of 0 or high value but I never seen values 1-14

One part of code fluctuates between 15 and 16 milliseconds but is sometimes 0... I'm wondering is this actually 14 but somehow I'm losing the value? 

The reference says:  "It is limited to the resolution of the system timer." but I'm not sure what this means.

Can I run the code section in a for loop 100 times, divide the answer by 100 and get reliable results? 

 

It's related on the method used by a computer to measure time. When you are not sure, then do some research to understand, for example you can read this document.
Reason: