Function interval

Returns a new IntervalTracker instance. IntervalTracker records the interval between each call to mark.

import { interval } from 'https://unpkg.com/ixfx/dist/trackers.js';

const t = interval();

// Call `mark` to record an interval
t.mark();
...
t.mark();

// Get average time in milliseconds between calls to `mark`
t.avg;

// Longest and shortest times are available too...
t.min / t.max

Interval tracker can automatically reset after a given number of samples:

// Reset after 100 samples
const t = interval({ resetAfterSamples: 100} );