X-Git-Url: https://git.xandkar.net/?p=beam_stats.git;a=blobdiff_plain;f=src%2Fbeam_stats_process.erl;h=5dc64d7676262a32a8fd5c3ac75e2719621f3a27;hp=b0b7da42d4db82f223de8cc299033dfa672fc4ee;hb=39ff67a62324705869d1ee364e98b17d14e70438;hpb=2cd7cf62e9b1e456c0ccc963d92a9170c3af8251 diff --git a/src/beam_stats_process.erl b/src/beam_stats_process.erl index b0b7da4..5dc64d7 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, _} -> @@ -78,15 +79,16 @@ print( { pid = Pid , registered_name = RegisteredNameOpt , ancestry = #beam_stats_process_ancestry - { raw_initial_call = InitialCallRaw - , otp_initial_call = InitialCallOTPOpt - , otp_ancestors = AncestorsOpt + { raw_initial_call = InitialCallRaw + , otp_initial_call = InitialCallOTPOpt + , otp_ancestors = AncestorsOpt } , status = Status , memory = Memory , 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.