, previous_context_switches :: non_neg_integer()
, current_context_switches :: non_neg_integer()
+
+ , reductions :: non_neg_integer()
}).
-define(T, #?MODULE).
, {output , CurrentIOBytesOut}
} = erlang:statistics(io),
{CurrentContextSwitches, 0} = erlang:statistics(context_switches),
+ {_ReductionsTotal, ReductionsDelta} = erlang:statistics(reductions),
?T
{ timestamp = os:timestamp()
, node_id = erlang:node()
, current_io_bytes_out = CurrentIOBytesOut
, previous_context_switches = 0
, current_context_switches = CurrentContextSwitches
+ , reductions = ReductionsDelta
}.
-spec update(t()) ->
, {output , CurrentIOBytesOut}
} = erlang:statistics(io),
{CurrentContextSwitches, 0} = erlang:statistics(context_switches),
+ {_ReductionsTotal, ReductionsDelta} = erlang:statistics(reductions),
?T
{ timestamp = os:timestamp()
, node_id = erlang:node()
, current_io_bytes_out = CurrentIOBytesOut
, previous_context_switches = PreviousContextSwitches
, current_context_switches = CurrentContextSwitches
+ , reductions = ReductionsDelta
}.
-spec export(t()) ->
, current_io_bytes_out = CurrentIOBytesOut
, previous_context_switches = PreviousContextSwitches
, current_context_switches = CurrentContextSwitches
+ , reductions = Reductions
}
) ->
#beam_stats
, io_bytes_in = CurrentIOBytesIn - PreviousIOBytesIn
, io_bytes_out = CurrentIOBytesOut - PreviousIOBytesOut
, context_switches = CurrentContextSwitches - PreviousContextSwitches
+ , reductions = Reductions
}.