X-Git-Url: https://git.xandkar.net/?p=beam_stats.git;a=blobdiff_plain;f=src%2Fbeam_stats_delta.erl;fp=src%2Fbeam_stats_delta.erl;h=42f2399f87950ab1de1f5dd3ccd1a098dc3459e4;hp=d563507455347d9183246af4ddb1f084001e06a2;hb=11e1cb97537476ce805262952a5c615000a6cf78;hpb=b2c364fd163d74df4914b6d4d5da42dec28368af diff --git a/src/beam_stats_delta.erl b/src/beam_stats_delta.erl index d563507..42f2399 100644 --- a/src/beam_stats_delta.erl +++ b/src/beam_stats_delta.erl @@ -9,6 +9,7 @@ , stop/1 , of_context_switches/1 , of_io/1 + , of_reductions/1 ]). -record(?MODULE, @@ -62,6 +63,18 @@ of_io(?T{erlang_statistics=Table}) -> , {io_bytes_out , DeltaOut} }. +% We can get between-calls-delta directly from erlang:statistics(reductions), +% but then if some other process also calls it - we'll get incorrect data on +% the next call. +% Managing deltas ourselves here, will at least reduce the possible callers to +% only those with knowledge of our table ID. +-spec of_reductions(t()) -> + non_neg_integer(). +of_reductions(?T{erlang_statistics=Table}) -> + Key = reductions, + {Current, _} = beam_stats_source:erlang_statistics(Key), + delta(Table, Key, Current). + -spec delta(ets:tid(), atom(), non_neg_integer()) -> non_neg_integer(). delta(Table, Key, CurrentTotal) ->