Board index » cppbuilder » GetTickCount - Accuracy question?

GetTickCount - Accuracy question?


2007-10-08 02:50:47 AM
cppbuilder31
Hi,
I've got a timer system that uses GetTickCount for calculate the number
ticks (in milliseconds), for timers etc.
This works fine on my laptop, which is quite a good HP running XP. But on
the target system running NT and is lower spec, its not accurate at all;
usually timers are 10-20% longer (eg. A 15 second timer ends up being about
18).
I've tried using the performance counter as a more accurate system, but I'm
not getting very good results even on my HP.
Has anyone got any clues or ideas for a tick counter for handling timers of
various lengths?
Regards,
Paul
PS. my perception of accuracy is based on the Now() time logged in a file
(hours,mins,secs,milliseconds).
 
 

Re:GetTickCount - Accuracy question?

For something you might try, look in the Windows help under multimedia for
the multimedia timers.
If the performance counter is giving similar results then I think your
problem is caused by multitasking Tick count is a count of time such as you
would do with a watch. It is not a count of the amount of time the OS has
given for the program to run. When another process is given a time slice
the tick count continues but your program is not running. Windows has many
services and tasks running at once. Your program shares the CPU time with
them.
. Ed
Quote
Paul at NCF wrote in message
news:47092a86$ XXXX@XXXXX.COM ...

I've got a timer system that uses GetTickCount for calculate the number
ticks (in milliseconds), for timers etc.

This works fine on my laptop, which is quite a good HP running XP. But on
the target system running NT and is lower spec, its not accurate at all;
usually timers are 10-20% longer (eg. A 15 second timer ends up being
about 18).

I've tried using the performance counter as a more accurate system, but
I'm not getting very good results even on my HP.

Has anyone got any clues or ideas for a tick counter for handling timers
of various lengths?

Regards,

Paul

PS. my perception of accuracy is based on the Now() time logged in a file
(hours,mins,secs,milliseconds).
 

Re:GetTickCount - Accuracy question?

BTW: For others' opinions on this you will probably experience better
results with the question about timing if you posted the question in the
Native API group where your question is on-topic.
. Ed
Quote
Paul at NCF wrote in message
news:47092a86$ XXXX@XXXXX.COM ...
 

{smallsort}

Re:GetTickCount - Accuracy question?

Hi,
Thanks for help, I'll try the nativeapi group.
BTW, I'm not trying to get the program tick/time counter (ie. CPU time
allocated to the application), I'm trying to determine a real time timings
and durations (for comms protocol timeouts etc, which have <150ms timeouts.
So it needs to be fairly accurate.
Paul
"Ed Mulroy [TeamB]" < XXXX@XXXXX.COM >wrote in message
Quote
If the performance counter is giving similar results then I think your
problem is caused by multitasking Tick count is a count of time such as
you would do with a watch. It is not a count of the amount of time the OS
has given for the program to run. When another process is given a time
slice the tick count continues but your program is not running. Windows
has many services and tasks running at once. Your program shares the CPU
time with them.