简体   繁体   English

Contiki中的任何函数是否与time.h中的clock_gettime()类似?

[英]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. 我想使用类似于time.hclock_gettime()函数的函数来计算函数调用所花费的时间。 I to include time.h , but found that it does not exist in Contiki. 我要包括time.h ,但发现它在Contiki中不存在。

You can use the rtimer functions for this task. 您可以使用rtimer函数执行此任务。 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. rtimer刻度的典型持续时间为1/32768秒。 If you need even greater precision, you're left with hardware-specific counters. 如果您需要更高的精度,那么您将拥有特定于硬件的计数器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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