aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tools/src
diff options
context:
space:
mode:
authorJohan Claesson <[email protected]>2017-05-15 23:25:13 +0200
committerJohan Claesson <[email protected]>2017-07-04 23:15:22 +0200
commit155f383b729406679c19098aee0386b9058d3161 (patch)
tree9daeaafe7fe694143b6b0e82b2e385937a541070 /lib/tools/src
parentc5ea4f9f5e28635e37541b2529cc39eb6252c40e (diff)
downloadotp-155f383b729406679c19098aee0386b9058d3161.tar.gz
otp-155f383b729406679c19098aee0386b9058d3161.tar.bz2
otp-155f383b729406679c19098aee0386b9058d3161.zip
fprof: Sum callers and callees
When sampling multiple processes and analyzing with totals true sum together all caller and callee entries which concerns the same function. Previous behaviour was to report each contributing entry.
Diffstat (limited to 'lib/tools/src')
-rw-r--r--lib/tools/src/fprof.erl20
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/tools/src/fprof.erl b/lib/tools/src/fprof.erl
index d1a4624419..436f68d12b 100644
--- a/lib/tools/src/fprof.erl
+++ b/lib/tools/src/fprof.erl
@@ -2636,22 +2636,32 @@ funcstat_pd(Pid, Func1, Func0, Clocks) ->
#funcstat{callers_sum = CallersSum,
callers = Callers} = FuncstatCallers ->
FuncstatCallers#funcstat{
- callers_sum = clocks_sum(CallersSum, Clocks, Func0),
- callers = [Clocks#clocks{id = Func1} | Callers]}
- end),
+ callers_sum = clocks_sum(CallersSum, Clocks, Func0),
+ callers = insert_call(Clocks, Func1, Callers)}
+ end),
put({Pid, Func1},
case get({Pid, Func1}) of
undefined ->
- #funcstat{callers_sum = #clocks{id = Func1},
+ #funcstat{callers_sum = #clocks{id = Func1},
called_sum = Clocks#clocks{id = Func1},
called = [Clocks#clocks{id = Func0}]};
#funcstat{called_sum = CalledSum,
called = Called} = FuncstatCalled ->
FuncstatCalled#funcstat{
called_sum = clocks_sum(CalledSum, Clocks, Func1),
- called = [Clocks#clocks{id = Func0} | Called]}
+ called = insert_call(Clocks, Func0, Called)}
end).
+insert_call(Clocks, Func, ClocksList) ->
+ insert_call(Clocks, Func, ClocksList, []).
+
+insert_call(Clocks, Func, [#clocks{id = Func} = C | T], Acc) ->
+ [clocks_sum(C, Clocks, Func) | T ++ Acc];
+insert_call(Clocks, Func, [H | T], Acc) ->
+ insert_call(Clocks, Func, T, [H | Acc]);
+insert_call(Clocks, Func, [], Acc) ->
+ [Clocks#clocks{id = Func} | Acc].
+
%% Sort a list of funcstat records,