X-Git-Url: https://git.xandkar.net/?p=beam_stats.git;a=blobdiff_plain;f=src%2Fbeam_stats_process.erl;h=3f2c9a41a7c971b84fffa71e34e283777b90bc1a;hp=b0b7da42d4db82f223de8cc299033dfa672fc4ee;hb=7dbc59b67d2cebe0e498ac4fd167cbaabed0e55b;hpb=65416582c9dcb3442edd532b2dbb2ace5e0dfa35 diff --git a/src/beam_stats_process.erl b/src/beam_stats_process.erl index b0b7da4..3f2c9a4 100644 --- a/src/beam_stats_process.erl +++ b/src/beam_stats_process.erl @@ -11,7 +11,7 @@ ]). -export( - [ of_pid/1 + [ of_pid/2 , get_best_known_origin/1 , print/1 ]). @@ -42,11 +42,11 @@ %% Public API %% ============================================================================ --spec of_pid(pid()) -> +-spec of_pid(pid(), beam_stats_delta:t()) -> none % when process is dead | {some, t()} % when process is alive . -of_pid(Pid) -> +of_pid(Pid, DeltasServer) -> try Dict = pid_info_exn(Pid, dictionary), Ancestry = @@ -65,6 +65,7 @@ of_pid(Pid) -> , total_heap_size = pid_info_exn(Pid, total_heap_size) , stack_size = pid_info_exn(Pid, stack_size) , message_queue_len = pid_info_exn(Pid, message_queue_len) + , reductions = pid_info_reductions(Pid, DeltasServer) }, {some, T} catch throw:{process_dead, _} -> @@ -87,6 +88,7 @@ print( , total_heap_size = TotalHeapSize , stack_size = StackSize , message_queue_len = MsgQueueLen + , reductions = Reductions }=T ) -> BestKnownOrigin = get_best_known_origin(T), @@ -103,6 +105,7 @@ print( "TotalHeapSize : ~p~n" "StackSize : ~p~n" "MsgQueueLen : ~p~n" + "Reductions : ~p~n" "~n", [ Pid , BestKnownOrigin @@ -115,6 +118,7 @@ print( , TotalHeapSize , StackSize , MsgQueueLen + , Reductions ] ). @@ -122,6 +126,16 @@ print( %% Private helpers %% ============================================================================ +-spec pid_info_reductions(pid(), beam_stats_delta:t()) -> + non_neg_integer(). +pid_info_reductions(Pid, DeltasServer) -> + case beam_stats_delta:of_process_info_reductions(DeltasServer, Pid) + of {some, Reductions} -> + Reductions + ; none -> + throw({process_dead, Pid}) + end. + pid_info_exn(Pid, Key) -> {some, Value} = pid_info_opt(Pid, Key), Value.