From 671c8091fbd7b12bcaf38b04af728a68033c1b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Thu, 27 May 2010 16:28:11 +0200 Subject: Add dump functionality to eprof --- lib/tools/src/eprof.erl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/tools/src/eprof.erl') diff --git a/lib/tools/src/eprof.erl b/lib/tools/src/eprof.erl index ca04b28be8..b3cedbc725 100644 --- a/lib/tools/src/eprof.erl +++ b/lib/tools/src/eprof.erl @@ -40,10 +40,10 @@ terminate/2, code_change/3]). -record(bpd, { - n = 0, - us = 0, - p = gb_trees:empty(), - mfa = [] + n = 0, % number of total calls + us = 0, % sum of uS for all calls + p = gb_trees:empty(), % tree of {Pid, {Mfa, {Count, Us}}} + mfa = [] % list of {Mfa, {Count, Us}} }). -record(state, { @@ -246,6 +246,9 @@ handle_call({logfile, File}, _From, #state{ fd = OldFd } = S) -> {reply, Error, S} end; +handle_call(dump, _From, #state{ bpd = Bpd } = S) when is_record(Bpd, bpd) -> + {reply, gb_trees:to_list(Bpd#bpd.p), S}; + handle_call(stop, _FromTag, S) -> {stop, normal, stopped, S}. @@ -439,6 +442,7 @@ filter_mfa([], Out, _, _) -> lists:reverse(Out); filter_mfa([{_, {C, T}}=Bpf|Bpfs], Out, Ct, Tt) when C >= Ct, T >= Tt -> filter_mfa(Bpfs, [Bpf|Out], Ct, Tt); filter_mfa([_|Bpfs], Out, Ct, Tt) -> filter_mfa(Bpfs, Out, Ct, Tt). +%% strings and format s({M,F,A}) -> s("~w:~w/~w",[M,F,A]); s(Term) -> s("~p", [Term]). -- cgit v1.2.3