简体   繁体   中英

Is there any function in Contiki similar to clock_gettime() from time.h?

I want to use a function similar to the clock_gettime() function from time.h to calculate the time taken in a function call. I to include time.h , but found that it does not exist in Contiki.

You can use the rtimer functions for this task. The clock module is not suitable, as it's not meant for real-time or high-precision time accounting.

rtimer_clock_t start;
start = RTIMER_NOW();
/* ...do stuff... */
printf("it took %u ticks to do stuff\n", RTIMER_NOW() - start);

The typical duration a rtimer tick is 1/32768 seconds. If you need even greater precision, you're left with hardware-specific counters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM