[time-nuts] Cheap jitter measurements
kb8tq at n1k.org
Wed Apr 11 09:36:39 EDT 2018
> On Apr 11, 2018, at 4:58 AM, Hal Murray <hmurray at megapathdsl.net> wrote:
> gem at rellim.com said:
>> It tests the time to do two back to back clock_gettime().
> That's the time it takes to read the clock. That's not what I mean by
> granularity but I think I see how you might use that word. The comment at
> the top of the code says "latency".
> When I hear "granularity", I think of the tick size of the clock. It's easy to measure a big tick size, read the clock, spin reading until it changes, subtract.
In the case of putting out a pulse, the clock to the timer you are using (or the i/o clock on the pin) most certainly creates granularity.
> Things get interesting if the tick size is less than the time it takes to read the clock. In that case, you may be able see the tick size with a histograms of the times to read the clock.
> With calibration, I can correct for the duration of time it takes to read the clock. I'm not sure how to do the calibration. In some cases it cancels out. Cache misses may be more significant.
> PS: Try running that code on an ARM.
Take a look at the clock specs on the various sub systems. If a pin is involved, you may have a 50 MHz clock spec. If your code is
coming from flash then it’s got it’s own clock that might be < 30 MHz.
Lots of nasty little gotcha’s.
One point is that these also impact how a piece of software “self evaluates” in the same environment. To the degree that some
of this is very hard to detect, it might get missed. That gets us back to the desire for an external measurement.
> And consider reading the clock 3 times and collecting 2 sets of data. The idea is that the first read takes all the cache misses so the time for the second read should be faster and cleaner.
> I see a tick size of 1 microsecond on a Pi 1, and 52 ns on a Pi 2 and Pi 3.
> These are my opinions. I hate spam.
> time-nuts mailing list -- time-nuts at febo.com
> To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
> and follow the instructions there.
More information about the time-nuts