Skip to content

NoobsEnslaver/exast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

Exast is an extremely fast erlang statistics library for simplest cases.

API

Data types:

name()
term()
frame_length()
pos_integer() (sec or count)
value()
integer() or term() for ‘gauge’
NameArgsDesc
new_tsma/2name(), frame_length()Register new time-limited simple moving average with FL sec length
new_ssma/2name(), frame_length()Register new size-limited simple moving average with FL maximum number of entries
new_cma/1name()Register new cumulative moving average
new_gauge/1name()Register new gauge
new_counter/1name()Register new counter
new_meter/1name()Register combined metric with 4 ‘rate’ - ‘one’, ‘five’, ‘fifteen’, ‘day’
notify/2name(), value()Add value() to metric, or set in case of gauge
get/0Retern all metrics with values
get/1name()Retrun value
delete/1name()Remove metric
new_rate/2name(), frame_length()Register new periodic nullable counter to measure rate

Examples

1> exast:new_ssma(test, 5).
ok
2> exast:get(test).
0.0
3> exast:notify(test, 10).
4> exast:get(test).
2.0                                             %% (10 + 0 + 0 + 0 + 0) / 5 == 2.0
5> exast:notify(test, 20).
6> exast:notify(test, 30).
7> exast:notify(test, 40).
8> exast:notify(test, 50).
9> exast:get(test).
30.0                                            %% (10 + 20 + 30 + 40 + 50) / 5 == 30.0
10> exast:notify(test, 0).
11> exast:get(test).
28.0                                            %% (20 + 30 + 40 + 50 + 0) / 5 == 28.0

12> FL = 10, ok = exast:new_rate(N, FL).
13> WorkerF = fun Loop()-> exast:notify(N, 10), timer:sleep(500), Loop() end.
14> ExpextedRate = 20.0.
15> MinRate = ExpextedRate - (ExpextedRate / FL).     % rate, as any time-limited datatype have precision 1/FL
16> Worker1 = spawn(WorkerF), timer:sleep(FL * 1100). % because last seconds data can be dpoped just before call 'get/1'
17> Rate0 = exast:get(N).
18> Rate0 >= MinRate and Rate0 =< ExpextedRate.
true
19> Worker2 = spawn(WorkerF),timer:sleep(FL * 1100).
20> Rate1 = exast:get(N).
21> Rate1 >= 2*MinRate and Rate1 =< 2*ExpextedRate.
true
22> exit(Worker1, kill), exit(Worker2, kill), timer:sleep(FL * 1100).
23> exast:get(N)
0.0

About

Erlang statistics library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages