From 49c657461866f0fe87de2ee7578b46b1b926db10 Mon Sep 17 00:00:00 2001 From: Stavros Aronis Date: Wed, 28 Mar 2012 16:11:36 +0200 Subject: Logfile-like statistics (enabled with --resources) --- lib/dialyzer/src/dialyzer_timing.erl | 37 +++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'lib/dialyzer/src/dialyzer_timing.erl') diff --git a/lib/dialyzer/src/dialyzer_timing.erl b/lib/dialyzer/src/dialyzer_timing.erl index 15d8795a37..b1a4bdc07c 100644 --- a/lib/dialyzer/src/dialyzer_timing.erl +++ b/lib/dialyzer/src/dialyzer_timing.erl @@ -32,13 +32,16 @@ -type timing_server() :: pid() | 'none'. --spec init(boolean()) -> timing_server(). +-spec init(boolean() | 'debug') -> timing_server(). init(Active) -> case Active of true -> io:format("\n"), spawn_link(fun() -> loop(now(), 0, "") end); + debug -> + io:format("\n"), + spawn_link(fun() -> debug_loop("") end); false -> none end. @@ -66,6 +69,38 @@ loop(LastNow, Size, Unit) -> Pid ! ok end. +debug_loop(Phase) -> + receive + Message -> + {Runtime,_} = statistics(wall_clock), + Procs = erlang:system_info(process_count), + ProcMem = erlang:memory(total), + Status = io_lib:format("~12w ~6w ~20w", [Runtime, Procs, ProcMem]), + case Message of + {stamp, Msg, _Now} -> + io:format("~s ~s_start\n", [Status, Msg]), + debug_loop(Msg); + {stamp, _Now} -> + io:format("~s ~s_stop\n", [Status, Phase]), + debug_loop(""); + {Pid, stop, _Now} -> + Pid ! ok; + {Pid, stop} -> + Pid ! ok; + _ -> + debug_loop(Phase) + end + after + 50 -> + {Runtime,_} = statistics(wall_clock), + Procs = erlang:system_info(process_count), + ProcMem = erlang:memory(total), + Status = io_lib:format("~12w ~6w ~20w", [Runtime, Procs, ProcMem]), + io:format("~s\n", [Status]), + debug_loop(Phase) + end. + + -spec start_stamp(timing_server(), string()) -> ok. start_stamp(none, _) -> ok; -- cgit v1.2.3