Most accurate way to get elapsed time (in microseconds) on iMX6?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Most accurate way to get elapsed time (in microseconds) on iMX6?

跳至解决方案
3,080 次查看
EdSutter
Senior Contributor II

The gettimeofday() call returns microseconds.

Is this the most accurate method or is there a better way?

--EDIT--

I did a bit more snooping, and tried clock_gettime(CLOCK_MONOTONIC_RAW,&t1)

to get a timestamp.  This appears to be reasonably accurate.  Does anyone have any experience

with this to agree or disagree?

Thoughts?

Ed

标记 (1)
0 项奖励
回复
1 解答
2,582 次查看
igorpadykov
NXP Employee
NXP Employee

Hi Ed

proper to use clock_gettime, see below

c - Measure time in Linux - getrusage vs clock_gettime vs clock vs gettimeofday? - Stack Overflow

https://blog.habets.se/2010/09/gettimeofday-should-never-be-used-to-measure-time

Best regards

chip

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

0 项奖励
回复
2 回复数
2,583 次查看
igorpadykov
NXP Employee
NXP Employee

Hi Ed

proper to use clock_gettime, see below

c - Measure time in Linux - getrusage vs clock_gettime vs clock vs gettimeofday? - Stack Overflow

https://blog.habets.se/2010/09/gettimeofday-should-never-be-used-to-measure-time

Best regards

chip

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
2,582 次查看
EdSutter
Senior Contributor II

Chip,

Yep, that's what I ended up using.  Shoulda posted it a while back.

Thanks,

Ed

0 项奖励
回复