int main( int argc, char** argv ) { tick_t start, time; tick_t tick, freq, res; printf( "Timer test\n" ); timer_lib_initialize(); res = 0xFFFFFFFFFFFFFFFFULL; freq = timer_ticks_per_second(); start = timer_current(); while( 1 ) { time = timer_current(); do { tick = timer_elapsed_ticks( time ); } while( !tick ); if( tick < res ) res = tick; if( timer_elapsed( start ) > 10.0 ) break; } printf( "Resolution: %lfms (%d ticks)\n", 1000.0 * (double)timer_ticks_to_seconds( res ), (int)res ); timer_lib_shutdown(); return 0; }
/** performance timer end, and return the time passed */ static unsigned int perf_end(void) { unsigned int end = 0; if (timer_current(perf_id, (void *)(&end)) < 0) { return 0; } if (start < end) { return (end - start); } else { return (0xFFFFFFFF - start + end); } }
/** performance timer start */ static void perf_start(void) { if (timer_current(perf_id, (void *)(&start)) < 0) { start = 0; } }