Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

GetTickCount is not good resolution...

Sephiroth, I would reccommend using performance timers. They are much more accurate. GetTickCount is limited by the resolution of the clock ticks. Look into the functions QueryPerformanceFrequency and QueryPerformanceCounter. They have resolution that is fast enough to benchmark opcodes.

Doctor Slush

Comments

  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    Well, that is true, but it's good enough to be used by the gaming industry as a fast and fairly effective way to get things done, and I'm merely following in those footsteps. The game I am working on is single-player only, and if it runs a few nanoseconds off on different machines, who's really going to notice? As it stands, if I place the app on my P2/233 and this P3/866 and run them, I see NO difference in anything, except the smaller monitor on the 233 :D!

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • Doctor SlushDoctor Slush Member Posts: 6
    GetTickCount() has a resolution of 40-50 ms. Performance timers can run at a Mhz or more.

    Its easy enough to implement... But whatever, if yours works, then its good.

    : Well, that is true, but it's good enough to be used by the gaming industry as a fast and fairly effective way to get things done, and I'm merely following in those footsteps. The game I am working on is single-player only, and if it runs a few nanoseconds off on different machines, who's really going to notice? As it stands, if I place the app on my P2/233 and this P3/866 and run them, I see NO difference in anything, except the smaller monitor on the 233 :D!
    :
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
    :
    :

  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    [b][red]This message was edited by Moderator at 2002-12-15 13:26:21[/red][/b][hr]
    It works in all the Quakes, Half-Life, Unreal, UT, etc, and it works on mine. However, I have NOT tested the app on an AMD system. I'm a gamer and programmer and need what everything is programed for, as well as the power that Pentiums offer. I'm not getting into that discussion on my forums though :D! Anyways, I am curious as to see how well this works on an AMD or even *shudder* Cyrix system.

    One other thing. If you have some other formula that would provide more accurate timing and not use more than 1%-3% of the CPU, I am intrested in seeing it. Mind you though, I test this game on systems ranging from P4s all the way to a tiny P200! So if the method uses 3% on a P4 that may be 75% on the P200 :D! The way I currently calculate movement rates is below.
    [code]
    float Ticker;

    Ticker = GetTickCount();
    DrawScreen(); //Draws the entire scene, consisting
    //of up to several billion triangles
    Ticker = (GetTickCount() - Ticker);
    Ticker = (Ticker / 1000);

    //I want to move 128 units, regardless of framerate
    blah blah = GetMoveRate(128, Ticker);

    //Now calculating movement units is simple!
    float GetMoveRate(float Desired, float SecsPerFrame)
    {
    float Actual;

    Actual = (Desired * SecsPerFrame);
    return Actual;
    }
    [/code]
    If one of your methods can tweak that and not use any CPU, I am VERY intrested in it.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]



  • Doctor SlushDoctor Slush Member Posts: 6
    I'm not exactly sure what you mean. Are you wondering if performance counters are not present on AMDs? I have tested it on my AMD Athalon 2.0 Ghz and it works fine. Any timing method that uses 1% of the processor is very wasteful!

    I cannot vouch for what UT, half-life et al use, but it seems odd that they would use GetTickCount. I'm going to go check my theory about GetTickCount and post some code to show you what I mean. I wasn't trying to start an argument or anything.

  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    If you want to check it out for the Half-Life engine, get the full SDK. UT you have to license the engine because the engine is more of a compiler than an engine. Check out the old Doom, Heretic, and Hexen sources as well. They used some kind of ticker way back in DOS :D!

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • Doctor SlushDoctor Slush Member Posts: 6
    Doom heretic and hexen reprogrammed the timer. Hi-Res timers are possible in DOS (I've been doing it for years) by reprogramming the clock using interrupts (int 8h I think it was, but that might be a different method). In windows, the clock cannot be reprogrammed (since the hardware is not directly accessible).

    As long as you are not running at higher than 30 fps, I guess you should be fine. When you get near 50 FPS, you get problems with the error. GetTickCount has a resolution of 20ms, so you might get inaccuracies at that frame rate (reciprocal of the frequency 60HZ=17ms). You need twice the resolution of your maximum interval, something akin to Shannon's Rule. So the highest frame rate you can go without any error would be 30 FPS.

    You might also want to consider using the multimedia timers.

    Check out http://www.geocities.com/hao510/w98timer/ to see what I mean about the various resolutions.
  • SephirothSephiroth Fayetteville, NC, USAMember Posts: 1,035
    Haven't heard about that before. My game, being OpenGL running on an NVidia chipset, with only ten or so triangles in object-space, is pumping well over 200fps virtually. Heck once I get the font-mapping completed I'll add a framerate display and get a screenshot for you :D! I expect the frames to drop a ton once I get some nice scenery going on though.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Sign In or Register to comment.