Skip to content

Commit

Permalink
Fix Dialyzer errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dszoboszlay committed Oct 28, 2021
1 parent 7b9173b commit 7b48fdb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
single load generator with the required arguments as part of the
function signature.

### Changed
- Fixed Dialyzer errors.

## [1.5.2] 2017-10-10
### Changed
- Fix stats for low CPS generators.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ REBAR ?= $(shell which rebar 2> /dev/null || which ./rebar)

DEPS_DIR = $(CURDIR)/deps

DIALYZER_OPTIONS := --fullpath --no_native -Wunderspecs
DIALYZER_OPTIONS := --fullpath --no_native -DDIALYZER_RUN -Wunderspecs

ERLANG_DIALYZER_APPS := compiler \
crypto \
Expand Down
23 changes: 10 additions & 13 deletions src/ponos_load_generator.erl
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
limit_reported :: boolean(),
name :: ponos:name(),
next_trigger_time :: number(),
intensities :: list(erlang:now()),
intensity :: ponos:intensity(),
intensities :: list(erlang:timestamp()),
intensity :: ponos:intensity() | undefined,
running_tasks :: integer(),
start :: erlang:timestamp(),
task_runner :: module(),
task_runner :: {module(), any()},
task :: ponos:task(),
tick_counter :: integer()
}).
Expand Down Expand Up @@ -317,7 +317,7 @@ do_prune_intensities(State) ->
Fun = fun(E) ->
time_passed_in_ms(Now, E) < ?PRUNE_INTENSITY_INTERVAL
end,
NewIntensities = [I1, I2
NewIntensities = [I1, I2
| lists:takewhile(Fun, T)],
state_set_intensities(State, NewIntensities);
_LessThanTwoElements ->
Expand Down Expand Up @@ -430,20 +430,15 @@ calc_current_load(State) ->
0.0
end.

do_calc_current_load(_State, 0) -> 0.0;
do_calc_current_load(_State, 0.0) -> 0.0;
do_calc_current_load(State, Period) ->
Intensities = state_get_intensities(State),
_CurrentLoad = min(state_get_intensity(State),(length(Intensities) - 1) / Period * 1000.0).

calc_top_modeled_load(State) ->
Start = state_get_start(State),
LoadSpec = state_get_load_spec(State),
case Start of
undefined ->
0.0;
Start ->
LoadSpec(trunc(time_passed_in_ms(os:timestamp(), Start)))
end.
LoadSpec(trunc(time_passed_in_ms(os:timestamp(), Start))).

time_passed_in_ms(Now, Then) ->
timer:now_diff(Now, Then) / 1000.
Expand Down Expand Up @@ -506,11 +501,12 @@ state_clear_limit_reported(State) ->

%%%_* EUnit Tests ======================================================
-ifdef(TEST).
-ifndef(DIALYZER_RUN).

calc_current_load_test_() ->
[ ?_assertEqual(0.0, calc_current_load(#state{intensities=[]}))
, ?_assertEqual(0.1, do_calc_current_load(#state{intensities=[1,2]}, 10000))
, ?_assertEqual(0.0, do_calc_current_load(#state{intensities=[1]}, 0))
, ?_assertEqual(0.1, do_calc_current_load(#state{intensities=[1,2]}, 10000.0))
, ?_assertEqual(0.0, do_calc_current_load(#state{intensities=[1]}, 0.0))
].

duration_is_exceeded_test_() ->
Expand Down Expand Up @@ -623,6 +619,7 @@ mk_state(Intensity, TriggerTime, LoadSpec) ->
(mk_state(Intensity, TriggerTime))#state{load_spec = LoadSpec}.

-endif.
-endif.

%%%_* Emacs ============================================================
%%% Local Variables:
Expand Down

0 comments on commit 7b48fdb

Please sign in to comment.