Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

timeseries

TimeSeries[T] stores timestamped samples with a bounded history. By default it keeps the latest 1000 samples, and add(value) records the value with the current monotonic timestamp. Tests can pass an explicit timestamp with add(value, ts).

Counter[T] builds on TimeSeries[T] for monotonic counters such as packet or byte counters. rate() returns an integer u64 units-per-second value for the normal counter use case, while rate_float() returns a fractional float when callers need that precision.

Usage

import timeseries

counter: timeseries.Counter[u64] = timeseries.Counter()

counter.add(u64(100))
counter.add(u64(280))

pps: ?u64 = counter.rate()
pps_float: ?float = counter.rate_float()

Both rate() and rate_float() accept an optional window in seconds:

pps_60s = counter.rate(60)

Development

Build the module:

acton build --skip-build src/timeseries.act

Run the embedded tests:

acton test --module timeseries

About

Simple Time series library

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors