Sunday, March 21, 2010

Sample App to test whether high res timers are available

#include
#include
#include


int check_timer(void);

int main()
{

if (check_timer())
fprintf(stderr,"NO: High resolution timers not available\n");
else
fprintf(stderr,"YES: High resolution timers are available\n");

return 0;

}

int check_timer(void)
{
struct timespec ts;

if (clock_getres(CLOCK_MONOTONIC, &ts))
return 1;

return (ts.tv_sec != 0 || ts.tv_nsec != 1);
}

No comments:

Post a Comment