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

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Jump to solution
542 Views
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
44 Views
NXP TechSupport
NXP TechSupport

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
45 Views
NXP TechSupport
NXP TechSupport

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
44 Views
Senior Contributor II

Chip,

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

Thanks,

Ed

0 Kudos