Welcome! Log In Create A New Profile

Advanced

Accurately measuring time (primarily for calculating the frame rate)

Posted by ThatOtherPerson 
Accurately measuring time (primarily for calculating the frame rate)
May 20, 2011 05:03AM
Quick question that I suspect has an obvious answer that I've overlooked: How can I accurately measure the passage of time on Wii? I previously used SDL_GetTicks (which returns the number of milliseconds that have passed since SDL was initialized) but that isn't an option when I'm not using SDL.
Re: Accurately measuring time (primarily for calculating the frame rate)
May 20, 2011 06:52AM
I use ticks_to_millisecs(gettime()); from the #include ogc/lwp_watchdog.h library in devkitpro. I don't know much else about it though.



Edited 1 time(s). Last edit at 05/20/2011 09:57AM by owen.
Re: Accurately measuring time (primarily for calculating the frame rate)
May 20, 2011 09:16AM
I think the "gettimeofday" function is a good alternative. It's pretty portable (mingw, linux, wii) and gives time as accurate as possible. (up to microseconds)
Re: Accurately measuring time (primarily for calculating the frame rate)
May 20, 2011 05:16PM
Here's what I've used in the past.

Uint64 get_tick_count()
{
	const Uint64 ticks = gettime();
	const Uint64 ms = ticks / TB_TIMER_CLOCK;
	return ms;
}



Edited 1 time(s). Last edit at 05/20/2011 05:17PM by scanff.
thanks everyone :)
Re: Accurately measuring time (primarily for calculating the frame rate)
May 22, 2011 01:15PM
Just take care with anything that might use time_t as at machine level it’s defined as long. ( so something may return u64, but internally uses far less resolution)

Can’t remember exactly but when I tried the library supplied timer methods, think it was somewhere around 15 seconds before time wrapped around.

This caught me out big time in my timer even code!

To get a true u64 high resolution timer for the Wii see nukes code… [wiibrew.org]
Re: Accurately measuring time (primarily for calculating the frame rate)
May 23, 2011 03:44AM
Quote
Titmouse
To get a true u64 high resolution timer for the Wii see nukes code… [wiibrew.org]
Ugh. Please don't introduce some external(obscure) dependency to your code just to reimplement something that is already in libogc - gettime() uses the same code and is definitely "true u64 high resolution".
Re: Accurately measuring time (primarily for calculating the frame rate)
May 26, 2011 10:33AM
D'oh, gettime() does indeed give exactly the same u64 results, nice (I problably used something like time() in the past).
Sorry, only registered users may post in this forum.

Click here to login