aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2010-05-27 16:28:11 +0200
committerBjörn-Egil Dahlberg <[email protected]>2010-06-09 14:26:05 +0200
commit671c8091fbd7b12bcaf38b04af728a68033c1b96 (patch)
treed6718ebe07a39d9f6c544be9b7a10bca481b8613
parent9a33a27398d4479c01dfd229091f5972c585b271 (diff)
downloadotp-671c8091fbd7b12bcaf38b04af728a68033c1b96.tar.gz
otp-671c8091fbd7b12bcaf38b04af728a68033c1b96.tar.bz2
otp-671c8091fbd7b12bcaf38b04af728a68033c1b96.zip
Add dump functionality to eprof
-rw-r--r--lib/tools/src/eprof.erl12
1 files changed, 8 insertions, 4 deletions
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]).