How to get elapsed time in milliseconds?

Started by Kweepa, Tue 06/09/2005 02:05:38

Previous topic - Next topic

Kweepa

I'm pretty sure there isn't a way, but I'd really like to accurately measure how long it takes to do something (specifically for my case: render stuff to the screen).
If it's not possible, I'd like to suggest it.
Something like
Code: ags

struct MillisecondTimer {
function Start();
function Stop();
function Reset();
int Read();
};

Cheers,
Steve
Still waiting for Purity of the Surf II

monkey0506

You could try reading off the raw times, getting the difference, then multiplying by 100.  But then the user could screw it up by changing their clock...So I'm sure that you've probably already thought of this and will say so with your next post...

Gilbert

Nope, raw time gives you measure in second unit only, it cannot provide the required precision, not even for 1/10 second.

This is a bit interesting, because if you need precise timing, game cycle coutning may not be reliable due to many reasons.

monkey0506

#3
Well...there's 100 milliseconds in a second...so if you took the difference in seconds and multiplied it by 100...it WOULD give you the difference in milliseconds...o_0

Also, raw time has nothing to do with game cycles (if that was even related...).

[EDIT:]

Nevermind...I see...he's wanting...oh...I feel stupid...I suppose that would be milliseconds to the nearest 100...

Gilbert


scotch

#5
I don't think it is possible in AGS, as it is.Ã,  Even the default windows time functions are quite grainy, (up to 50ms steps), but there are some multimedia timer functions that will give lower granularity (it can still be fiddly...)
If you just want it for testing for bottlenecks in your engine, you could try this: http://scotch.agagames.com/ags_millis.dll I just made it using mmlib's timer thing.Ã,  The only function it has is "int GetGameMillis()", which returns the number of milliseconds since the game started.Ã,  This will wrap every 20 days or so, due to the limitations of ints, but that shouldn't be an issue ;)
On my system it is accurate enough to the millisecond, it may not be on some systems.
Presumably you run AGS on a mac and this plugin is all useless anyway, oh well!

Kweepa

#6
Quote from: scotch on Tue 06/09/2005 05:08:58
Presumably you run AGS on a mac and this plugin is all useless anyway, oh well!
Actually, no I don't. I am trying to avoid the use of plugins though - it seems like cheating. Although to get a game done I might just crack. The average user doesn't care how it's done after all. They just want the experience to be smooth.

If you want a better timer in a (Windows) plugin, you could consider QueryPerformanceFrequency() and QueryPerformanceCounter(). They're much higher resolution than timeGetTime().

Cheers!
Steve
Still waiting for Purity of the Surf II

SMF spam blocked by CleanTalk