gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Measure

#173803 - lorenicka - Sat May 01, 2010 6:54 pm

I would like to know how can I measure how many time the DS takes to make an instruction.

There is any clock or something I could read (like the TSC in a Pentium) ? or any library that allows me to do that?

I mean something like:

getTime()
INSTRUCTION
getTime()

Thanks

#173805 - elhobbs - Sat May 01, 2010 11:31 pm

The ds has hardware timers. Do a search you will find info

#173810 - Ruben - Sun May 02, 2010 5:55 am

I believe this is what you are after

Code:
(Taken from libnds/timers.h)
/*! \fn void cpuStartTiming(u32 timer);
   \brief begins cpu Timing using two timers for 32bit resolution.
   \param timer The base hardware channel to use (0 - 2)
   
   
*/
void cpuStartTiming(u32 timer);

/*! \fn void cpuEndTiming();
   \brief ends cpu Timing
   \return The number of ticks which have elapsed since cpuStartTiming
*/
u32 cpuEndTiming();

Video runs at 59.8261Hz with a 5.586Hz dot-clock. I trust you can work out the rest.

#173813 - Dwedit - Sun May 02, 2010 4:15 pm

I'll assume you mean MHz for the dot clock...
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#173822 - Ruben - Sun May 02, 2010 10:58 pm

Erm, yep xP

#173831 - Miked0801 - Mon May 03, 2010 6:42 pm

You can also count LY lines as a poor man's version of profiling. Beware that interrupts can throw off your profiling though if you do it at this simple of a level.