- { timestamp = Timestamp
- , node_id = NodeID
- , memory = Memory
- , io_bytes_in = CurrentIOBytesIn - PreviousIOBytesIn
- , io_bytes_out = CurrentIOBytesOut - PreviousIOBytesOut
+ { timestamp = Timestamp
+ , node_id = NodeID
+ , memory = Memory
+ , io_bytes_in = CurrentIOBytesIn - PreviousIOBytesIn
+ , io_bytes_out = CurrentIOBytesOut - PreviousIOBytesOut
+ , context_switches = CurrentContextSwitches - PreviousContextSwitches
+ , reductions = Reductions
+ , run_queue = RunQueue
+ , ets = ETS
+ , processes = Processes
+ }.
+
+snapshots_new() ->
+ #snapshots
+ { memory = beam_stats_source:erlang_memory()
+ , processes = beam_stats_processes:collect()
+ , run_queue = beam_stats_source:erlang_statistics(run_queue)
+ , ets = beam_stats_ets:collect()
+ }.
+
+deltas_new() ->
+ {_ReductionsTotal, ReductionsDelta} = beam_stats_source:erlang_statistics(reductions),
+ #deltas
+ { reductions = ReductionsDelta
+ }.
+
+totals_new() ->
+ { {input , IOBytesIn}
+ , {output , IOBytesOut}
+ } = beam_stats_source:erlang_statistics(io),
+ {ContextSwitches, 0} = beam_stats_source:erlang_statistics(context_switches),
+ #totals
+ { io_bytes_in = IOBytesIn
+ , io_bytes_out = IOBytesOut
+ , context_switches = ContextSwitches
+ }.
+
+totals_empty() ->
+ #totals
+ { io_bytes_in = 0
+ , io_bytes_out = 0
+ , context_switches = 0