Keeps track of the total, min, max and avg in a stream of values. By default values are not stored.
Usage:
import { number } from 'https://unpkg.com/ixfx/dist/trackers.js';const t = number();t.seen(10);t.avg / t.min/ t.maxt.initial; // initial valuet.size; // number of seen valuest.elapsed; // milliseconds since intialisationt.last; // last value Copy
import { number } from 'https://unpkg.com/ixfx/dist/trackers.js';const t = number();t.seen(10);t.avg / t.min/ t.maxt.initial; // initial valuet.size; // number of seen valuest.elapsed; // milliseconds since intialisationt.last; // last value
To get { avg, min, max, total }
{ avg, min, max, total }
t.getMinMax() Copy
t.getMinMax()
Use t.reset() to clear everything.
t.reset()
Trackers can automatically reset after a given number of samples
// reset after 100 samplesconst t = number({ resetAfterSamples: 100 }); Copy
// reset after 100 samplesconst t = number({ resetAfterSamples: 100 });
To store values, use the storeIntermediate option:
storeIntermediate
const t = number({ storeIntermediate: true }); Copy
const t = number({ storeIntermediate: true });
Difference between last value and initial value:
t.relativeDifference(); Copy
t.relativeDifference();
Get raw data (if it is being stored):
t.values; // array of numberst.timestampes; // array of millisecond times, indexes correspond to t.values Copy
t.values; // array of numberst.timestampes; // array of millisecond times, indexes correspond to t.values
Keeps track of the total, min, max and avg in a stream of values. By default values are not stored.
Usage:
To get
{ avg, min, max, total }
Use
t.reset()
to clear everything.Trackers can automatically reset after a given number of samples
To store values, use the
storeIntermediate
option:Difference between last value and initial value:
Get raw data (if it is being stored):