From c9a5df583c36b09113f17b4c1d17baa4be94e182 Mon Sep 17 00:00:00 2001 From: Juan Facorro Date: Sun, 1 Jul 2018 23:18:12 +0200 Subject: [PATCH] Avoid having to post-process file by generating the correct output --- src/eflame.erl | 16 +++++++--------- stack_to_flame.sh | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/eflame.erl b/src/eflame.erl index c86933e..7311379 100644 --- a/src/eflame.erl +++ b/src/eflame.erl @@ -212,7 +212,7 @@ stack_collapse(Stack) -> entry_to_iolist({M, F, A}) -> [ atom_to_binary(M, utf8), <<":">> , atom_to_binary(F, utf8), <<"/">> - , integer_to_list(A) + , integer_to_binary(A) ]; entry_to_iolist(A) when is_atom(A) -> [atom_to_binary(A, utf8)]. @@ -231,13 +231,11 @@ dump_to_iolist(Pid, Stacks) -> dump_to_iolist(_PidList, [], Result) -> Result; dump_to_iolist(PidList, [{N, Stack} | Rest], Result) -> - Item = stack_to_iolist(PidList, Stack), - Items = lists:duplicate(N, Item), - dump_to_iolist(PidList, Rest, [Items | Result]); -dump_to_iolist(PidList, [Stack | Rest], Result) -> - Item = stack_to_iolist(PidList, Stack), + Item = stack_to_iolist(PidList, N, Stack), dump_to_iolist(PidList, Rest, [Item | Result]). --spec stack_to_iolist(string(), list()) -> iolist(). -stack_to_iolist(PidList, Stack) -> - [PidList, <<";">>, stack_collapse(Stack), <<"\n">>]. +-spec stack_to_iolist(string(), integer(), list()) -> iolist(). +stack_to_iolist(PidList, N, Stack) -> + [ PidList, <<";">>, stack_collapse(Stack) + , <<" ">>, integer_to_binary(N) + , <<"\n">>]. diff --git a/stack_to_flame.sh b/stack_to_flame.sh index 8ca2dfc..da3df18 100755 --- a/stack_to_flame.sh +++ b/stack_to_flame.sh @@ -2,4 +2,4 @@ me="$(dirname $0)" -uniq -c | awk '{print $2, " ", $1}' | $me/flamegraph.pl +$me/flamegraph.pl $1