View Full Version : Timer trouble. need your help people. Test time

12-06-2006, 12:06 AM
I have posted about this topic already, and ina few weeks I get a new G.card so hopefully this problem will go away.

Dxtimer and all threaded timers are running at weird framerates. Here is a sample

Interval of 0: realtime (only 1 that actually works)

interval of 1-10: 64 FPS and not 1000-100, interval 11-20: 40FPS for entire range.

On other machies the above values follow exact same pattern but the values start off different. i.e. 1-10: 92 FPS, 11-20 52FPS ....

Weirder still, if I open dxdiag test page, it somehow rectifie the bug and the timer then runs at correct speed, after closing the page, back we go to ludicrous frame rate.

The bug is also not present when delphi is actually loaded. If it is shut down, the exe does not run properly.

I did not have this problem when i was using win 2000, only now that i use XP do i get the problem.

Maybe it is a fault of my graphics card, without another system to compile the exe i have made it is impossible to conclude anything.

This is where you lot come in. I have uploaded a test exe. I need some of you to download it, run the exe, record what speeds you are getting from it. I have set the interval to 1. If your system is playing it correctly the frame rate will be around 1000. On mine it is 64.

Then, I need you to recompile the source code that is with the exe. upload the NEW exe that has been compiled by YOUR system. Make sure the exe has all files needed to run on ANY computer (travellers last exe only runs on computers with certain needed files...maybe something taken away at runtime?)

Anyway, here is the file and souce code:


12-06-2006, 06:07 AM
Do you have a dual core or Hyperthreaded processor? I have heard of problems with timers on these processors. The normal GetTickCount apparantly runs reliably but the more detailed timers do not.

I dont have a fix for it as I always use GetTickCount.

12-06-2006, 09:52 AM
Yea, you're almost always better off just using GetTickCount or QueryPerformanceCounter, but I dont know how accurate/fast/stable that is...

12-06-2006, 11:17 AM
well, tried that but doesn't seem to good for me with delphix. I mean, I should be able to use dxtimer. If this is an issue at compile time, there isnt a problem. If it is an issue depending on computer then we have a serious problem with people using the dxtimer

I have a hyper threaded machine, but it is turned off, it still did it even when I was using a normal AMD athlon....so that isn't the problem. It is something to do with directx and XP...maybe also my g.card.

Why would it work properly if delphi is running or dxdiag loaded up....its very strange?

Any of you downloaded that program to see if it runs right on your system?

11-07-2006, 12:16 PM
The problem is almost definately because of XP.

I have now changed graphic cardand type, motherboard, processor...to cut it short everything. SP2 did not correct ther problem either.

Someone needs to look into this properly because Windows 2000 has no such problems., I installed 2000 before installing xp again. 2000 runs with NO problems. The timers run correct, the idle loops and thus game run at the correct speed.

The real weird thing is that if I am using an idle loop or realtime the problem STILL persists. something still makes the loop execute at less than 60 FPS (around 32 half of it)

It is almost as if the timer problem is duplicated in other areas as well such as drawing in delphix.

Whatever it is, someone needs to look hard at delphi, delphix because something is amiss here with xp for certain.

15-07-2006, 08:40 PM
Well been hard at work trying to fully understand this. It turns out XP is not the problem so that only leaves Directx V 9 which I will check.

I have changed: Motherboard, CPU, G Card, memory, OS, delphix , undelphix version. delphi version (from 4 to 7), service packs.

Infact I have changed everything and still...timers running wrong, game running wrong EVEN in idleloops.

It is a most bizarre thing and the only thing it can now possibly be is DX9.

Opening Dxdiag in the background as I have said for 1 bizarre reason or another makes the game run correctly and all timers run correctly. I can hardly ask my user to do that every time they want to play the game right:)

I will check DX7 and see what happens.


Win2000 with directx 7 didn't solve anything. Same thing. So something even more wrong than I first thought.

I will now go back to win98 and test that:) but if all you guys have 0 probs, then I am stuck! I mean what the hell could it be? My monitor? That is thew only thing left to change!

16-07-2006, 08:59 AM
ummm, I don't really know about the problem, but what I've seen the strange timer runnings was the Windows Timer... That thing has 64FPS, 32FPS, etc. Maybe there's a Windows Timer running there instead of a DXTimer somehow?

Oh, yea, and vSync would only try to cap the FPS at standard vSync values, like 60, 70, 75, 85, 100, 120, 160. Don't think the "monitor" could interfere with the FPS in any diff way :)

16-07-2006, 02:29 PM

18-07-2006, 06:25 PM
The download link didn't work for me.

But to me it sounds like you have a computer with two processors and your timer code is using something like RDTSC. When you have more than 1 app running, I guess WinXP will assign each to a single processor, but when your game is alone, but processors are used. The RDTSC uses the processor's time counter which could be different on each processor.

18-07-2006, 07:36 PM
Bumped into an invalid link.

I can say Hyper threaded processors have no problems with timers, or at least none that I have ever noticed.

I doubt dual core cpus would have any problems either. I would like to see your code. Have you tried your code on any one else's machine?

I doubt there is a fundamental error in timers so I suspect it is yourcode that may be to blame or your particular computer. Do you have problems running other games?

18-07-2006, 07:38 PM
[quote="Wiering"]The download ]

This same problem can occur on a HyperThreading processor as well. Try placing SetThreadAffinityMask(GetCurrentThread(), 1); in your application initialization code (NOT FORM CODE, APP CODE).

18-07-2006, 09:24 PM

19-07-2006, 01:56 AM
I tried it and the same thing happens here (only works when IDE is running). I uploaded my compiled version (compiled in Delphi 3). I added labels that display the lost time.

Whatever it is, it starts after 4 or 5 seconds, if you run the test for only 5 sec, it works fine.

19-07-2006, 01:58 AM