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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

Jump to solution
1,771 Views
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

Tags (1)
0 Kudos
1 Solution
1,273 Views
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!

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

View solution in original post

0 Kudos
2 Replies
1,274 Views
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 Kudos
1,273 Views
EdSutter
Senior Contributor II

Chip,

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

Thanks,

Ed

0 Kudos