package octez-libs

  1. Overview
  2. Docs
A package that contains multiple base libraries used by the Octez suite

Install

Dune Dependency

Authors

Maintainers

Sources

tezos-18.0.tar.gz
sha256=dbc3b675aee59c2c574e5d0a771193a2ecfca31e7a5bc5aed66598080596ce1c
sha512=b97ed762b9d24744305c358af0d20f394376b64bfdd758dd4a81775326caf445caa57c4f6445da3dd6468ff492de18e4c14af6f374dfcbb7e4d64b7b720e5e2a

doc/octez-libs.stdlib-unix/Tezos_stdlib_unix/Moving_average/index.html

Module Tezos_stdlib_unix.Moving_averageSource

Moving averages.

This module implements bandwidth counters based on (cumulative) exponential moving average. Each counter is identified by an integer. They are stored in an internal hash table.

See i.e. https://en.wikipedia.org/wiki/Moving_average#Exponential_moving_average for the algorithm.

Sourcetype t

Type of one bandwidth counter.

Sourcetype state

Internal state of the worker handling a family of counters.

Sourceval fresh_state : id:string -> refresh_interval:float -> state

fresh_state ~id ~refresh_interval initializes the state of a worker handling a family of counter. The worker wakes up every refresh_interval seconds. id is a string identifier used for distinguishing distinct Moving_average workers..

Sourceval create : state -> init:int -> alpha:float -> t

create state ~init ~alpha is a counter with initial value init and factor alpha. The counter is added to the state. It is not removed automatically: it must be removed manually.

Sourceval destroy : state -> t -> unit

destroy state -> t removes counter t from the internal state.

Sourceval add : t -> int -> unit

add state t v adds v to the counter t.

Sourceval on_update : state -> (unit -> unit) -> unit

on_update state f registers f to be called on each update of the internal worker associated to state.

Sourceval updated : state -> unit Lwt_condition.t

updated state is a condition variable that gets signaled on each update of the internal worker..

Sourcetype stat = {
  1. total : int64;
  2. average : int;
}
Sourceval stat : t -> stat

stat t is a stat record reflecting the state of t at the time of the call.

OCaml

Innovation. Community. Security.