PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

GetTickCount Resolution - Program to test it

Here's a small program I wrote that defines the resoltion of the GetTickCount() by checking how many times it returns a new value during a 5 seconds period.
Could you people run it and post the result it gives?

ARM Version
SH3 Version
MIPS Version
PC Version
Pocket PC 2000 Emulator Version
Pocket PC 2002 Emulator Version

On my PC it gives 10ms accuracy...
I haven't looked at your programs, but in my own research I can confirm that on my PC GetTickCount definately has a 10ms resolution. In fact if you had something like this:

Code:
for (int i = 0; i < 5; i++)
{
printf("%d\n", GetTickCount());
Sleep(1);
}


You get something like:
1000010
1000020
1000030
1000040
1000050

which is the same output you'd get if you put a Sleep(10) in there. What I'm saying is that GetTickCount behaves even more strangely than one would imagine - depending on whether or not it rounds up or down, I would imagine the output to be more like:
1000010
1000010
1000010
1000020
1000020

or something. Unless, of course, Sleep(1) takes much more than just 1ms.

If you are looking for something to use that is a little better, try the QueryPerformanceCounter and QueryPerformanceFrequency methods. These work better than GetTickCount on the PC, and I believe they are supported in PPC as well.

ryanc
angedelamort · 25 Apr 2003, 19:24 UTC
your program is not good... outputting is slow. You should add it to a temp variable instead and do the average after that.

but I wonder why GetTickCount() is so slow on a pc... But, as you said, Queryperformance counter is better for more precision.
I see you people don't trust me enough to run an unknown executable... That's ok, I would do the same :D
You can download the source of the program and compile yourself if you prefer: GetTickCountRes.cpp

(oh, and please do not post messages complaining about my stupid coding habits :D )
OK, I won't comment on your code.

I wrote my own test. On Windows XP the resolution is of GetTickCount is 10 ms. On my iPaq 3670 the resolution is 1 ms.

[edit] The resolution on my Toshiba e740 is 1 ms too.
Sergey Chaban · 28 Apr 2003, 12:25 UTC
FWIW: if GetTickCount or QueryPerformanceCounter resolution is not enough for some reason than it's possible to use on-chip OSCR timer on both StrongARM & XScale.
Intel has a library to access the timer (ixs_timer.lib), which is included with their Performance Primitives lib.
OSCR timer increments approx. every 271 uSecs, and according to Intel their OSCR functions have much lower overhead than QueryPerformanceCounter.
Intel also have another library to access performance counters on XScale.

SC