aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2017-08-24 16:32:44 +0200
committerLukas Larsson <[email protected]>2017-08-24 16:32:44 +0200
commitd728fc61bc2d82ea4d7246b16a9b04694971b87b (patch)
tree177629b660eeca07503f6dbd28041d3776e48ae4
parent6c8d1ac3112a0cc61849741fd667bbccfa01ee54 (diff)
parent25978542a49e36729ca8f856b9949ec895fe58c0 (diff)
downloadotp-d728fc61bc2d82ea4d7246b16a9b04694971b87b.tar.gz
otp-d728fc61bc2d82ea4d7246b16a9b04694971b87b.tar.bz2
otp-d728fc61bc2d82ea4d7246b16a9b04694971b87b.zip
Merge branch 'johanclaesson/fprof/PR-1460/OTP-14500' into maint
* johanclaesson/fprof/PR-1460/OTP-14500: fprof: Sum callers and callees
-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,