{ timestamp :: erlang:timestamp()
, node_id :: atom()
, memory :: [{atom(), non_neg_integer()}]
+
, previous_io_bytes_in :: non_neg_integer()
, previous_io_bytes_out :: non_neg_integer()
, current_io_bytes_in :: non_neg_integer()
, current_io_bytes_out :: non_neg_integer()
+
+ , previous_context_switches :: non_neg_integer()
+ , current_context_switches :: non_neg_integer()
}).
-define(T, #?MODULE).
{ {input , CurrentIOBytesIn}
, {output , CurrentIOBytesOut}
} = erlang:statistics(io),
+ {CurrentContextSwitches, 0} = erlang:statistics(context_switches),
?T
{ timestamp = os:timestamp()
, node_id = erlang:node()
, previous_io_bytes_out = 0
, current_io_bytes_in = CurrentIOBytesIn
, current_io_bytes_out = CurrentIOBytesOut
+ , previous_context_switches = 0
+ , current_context_switches = CurrentContextSwitches
}.
-spec update(t()) ->
update(?T
{ previous_io_bytes_in = PreviousIOBytesIn
, previous_io_bytes_out = PreviousIOBytesOut
+ , previous_context_switches = PreviousContextSwitches
}
) ->
{ {input , CurrentIOBytesIn}
, {output , CurrentIOBytesOut}
} = erlang:statistics(io),
+ {CurrentContextSwitches, 0} = erlang:statistics(context_switches),
?T
{ timestamp = os:timestamp()
, node_id = erlang:node()
, previous_io_bytes_out = PreviousIOBytesOut
, current_io_bytes_in = CurrentIOBytesIn
, current_io_bytes_out = CurrentIOBytesOut
+ , previous_context_switches = PreviousContextSwitches
+ , current_context_switches = CurrentContextSwitches
}.
-spec export(t()) ->
, previous_io_bytes_out = PreviousIOBytesOut
, current_io_bytes_in = CurrentIOBytesIn
, current_io_bytes_out = CurrentIOBytesOut
+ , previous_context_switches = PreviousContextSwitches
+ , current_context_switches = CurrentContextSwitches
}
) ->
#beam_stats
, memory = Memory
, io_bytes_in = CurrentIOBytesIn - PreviousIOBytesIn
, io_bytes_out = CurrentIOBytesOut - PreviousIOBytesOut
+ , context_switches = CurrentContextSwitches - PreviousContextSwitches
}.