Implement printing process stats.
[beam_stats.git] / src / beam_stats_process.erl
index a06c48e..412b4f8 100644 (file)
@@ -9,6 +9,7 @@
 
 -export(
     [ of_pid/1
+    , print/1
     ]).
 
 -type status() ::
 -type t() ::
     ?T{}.
 
+%% ============================================================================
+%% Public API
+%% ============================================================================
+
 -spec of_pid(pid()) ->
     t().
 of_pid(Pid) ->
@@ -42,6 +47,52 @@ of_pid(Pid) ->
     , message_queue_len = pid_info_exn(Pid, message_queue_len)
     }.
 
+-spec print(t()) ->
+    ok.
+print(
+    ?T
+    { pid               = Pid
+    , registered_name   = RegisteredNameOpt
+    , 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
+    }
+) ->
+    io:format("--------------------------------------------------~n"),
+    io:format(
+        "Pid               : ~p~n"
+        "RegisteredNameOpt : ~p~n"
+        "InitialCallRaw    : ~p~n"
+        "InitialCallOTPOpt : ~p~n"
+        "AncestorsOpt      : ~p~n"
+        "Status            : ~p~n"
+        "Memory            : ~p~n"
+        "TotalHeapSize     : ~p~n"
+        "StackSize         : ~p~n"
+        "MsgQueueLen       : ~p~n"
+        "~n",
+        [ Pid
+        , RegisteredNameOpt
+        , InitialCallRaw
+        , InitialCallOTPOpt
+        , AncestorsOpt
+        , Status
+        , Memory
+        , TotalHeapSize
+        , StackSize
+        , MsgQueueLen
+        ]
+    ).
+
+%% ============================================================================
+%% Private helpers
+%% ============================================================================
+
 pid_info_exn(Pid, Key) ->
     {some, Value} = pid_info_opt(Pid, Key),
     Value.
This page took 0.021874 seconds and 4 git commands to generate.