Verify increment is all 0s before applying drop
This commit is contained in:
parent
c3cfc4ace4
commit
35085496e0
|
|
@ -202,12 +202,16 @@ add_element(TS, Evt, #slide{last = Last, size = Sz, incremental = true,
|
||||||
buf1 = Buf1} = Slide, Wrap) ->
|
buf1 = Buf1} = Slide, Wrap) ->
|
||||||
N1 = N+1,
|
N1 = N+1,
|
||||||
Total = add_to_total(Evt, Total0),
|
Total = add_to_total(Evt, Total0),
|
||||||
case Buf1 of
|
%% Total could be the same as the last sample, by adding and substracting
|
||||||
[{_, Total}, drop | Tail] ->
|
%% the same amout to the totals. That is not strictly a drop, but should
|
||||||
|
%% generate new samples.
|
||||||
|
%% I.e. 0, 0, -14, 14 (total = 0, samples = 14, -14, 0, drop)
|
||||||
|
case {is_zeros(Evt), Buf1} of
|
||||||
|
{true, [{_, Total}, drop | Tail]} ->
|
||||||
%% Memory optimisation
|
%% Memory optimisation
|
||||||
Slide#slide{buf1 = [{TS, Total}, drop | Tail],
|
Slide#slide{buf1 = [{TS, Total}, drop | Tail],
|
||||||
last = TS};
|
last = TS};
|
||||||
[{_, Total} | Tail] ->
|
{true, [{_, Total} | Tail]} ->
|
||||||
%% Memory optimisation
|
%% Memory optimisation
|
||||||
Slide#slide{buf1 = [{TS, Total}, drop | Tail],
|
Slide#slide{buf1 = [{TS, Total}, drop | Tail],
|
||||||
last = TS};
|
last = TS};
|
||||||
|
|
@ -269,6 +273,21 @@ add_to_total({A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14,
|
||||||
B9 + A9, B10 + A10, B11 + A11, B12 + A12, B13 + A13, B14 + A14, B15 + A15, B16 + A16,
|
B9 + A9, B10 + A10, B11 + A11, B12 + A12, B13 + A13, B14 + A14, B15 + A15, B16 + A16,
|
||||||
B17 + A17, B18 + A18, B19 + A19}.
|
B17 + A17, B18 + A18, B19 + A19}.
|
||||||
|
|
||||||
|
is_zeros({0}) ->
|
||||||
|
true;
|
||||||
|
is_zeros({0, 0}) ->
|
||||||
|
true;
|
||||||
|
is_zeros({0, 0, 0}) ->
|
||||||
|
true;
|
||||||
|
is_zeros({0, 0, 0, 0, 0, 0, 0}) ->
|
||||||
|
true;
|
||||||
|
is_zeros({0, 0, 0, 0, 0, 0, 0, 0}) ->
|
||||||
|
true;
|
||||||
|
is_zeros({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}) ->
|
||||||
|
true;
|
||||||
|
is_zeros(_) ->
|
||||||
|
false.
|
||||||
|
|
||||||
add_ret(false, _, Slide) ->
|
add_ret(false, _, Slide) ->
|
||||||
Slide;
|
Slide;
|
||||||
add_ret(true, Flag, Slide) ->
|
add_ret(true, Flag, Slide) ->
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ foldl_incremental_test(_Config) ->
|
||||||
prop_foldl_incremental() ->
|
prop_foldl_incremental() ->
|
||||||
?FORALL({Elements, Int, Sleep}, {non_empty(elements_gen()), choose(1,9), choose(1,9)},
|
?FORALL({Elements, Int, Sleep}, {non_empty(elements_gen()), choose(1,9), choose(1,9)},
|
||||||
begin
|
begin
|
||||||
Slide = exometer_slide:new(1000, [{interval, Int},
|
Slide = exometer_slide:new(60 * 1000, [{interval, Int},
|
||||||
{incremental, true}]),
|
{incremental, true}]),
|
||||||
Slide1 = lists:foldl(fun(E, Acc) ->
|
Slide1 = lists:foldl(fun(E, Acc) ->
|
||||||
%% sometimes the data will be within the intervals
|
%% sometimes the data will be within the intervals
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue