diff options
author | Björn Gustavsson <[email protected]> | 2017-09-22 07:24:51 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2017-09-22 08:23:42 +0200 |
commit | 79f28cfd8df1b700baff0df5e3d766d0a5592581 (patch) | |
tree | 8f3704fad48efe47c73a47d9a3c106e17a03dba0 | |
parent | c9e444ff6bf5f3cda8f2503e35a0ac5f9a8b1a45 (diff) | |
download | otp-79f28cfd8df1b700baff0df5e3d766d0a5592581.tar.gz otp-79f28cfd8df1b700baff0df5e3d766d0a5592581.tar.bz2 otp-79f28cfd8df1b700baff0df5e3d766d0a5592581.zip |
Speed up erts_debug:df()
The test case erts_debug_SUITE:df/1 in the emulator test suite is
about 4 times faster with this change.
-rw-r--r-- | lib/kernel/src/erts_debug.erl | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/kernel/src/erts_debug.erl b/lib/kernel/src/erts_debug.erl index 480db6814e..2887014c1c 100644 --- a/lib/kernel/src/erts_debug.erl +++ b/lib/kernel/src/erts_debug.erl @@ -378,16 +378,11 @@ df(Mod, Func, Arity) when is_atom(Mod), is_atom(Func) -> catch _:_ -> {undef,Mod} end. -dff(File, Fs) when is_pid(File), is_list(Fs) -> - lists:foreach(fun(Mfa) -> - disassemble_function(File, Mfa), - io:nl(File) - end, Fs); -dff(Name, Fs) when is_list(Name) -> - case file:open(Name, [write]) of +dff(Name, Fs) -> + case file:open(Name, [write,raw,delayed_write]) of {ok,F} -> try - dff(F, Fs) + dff_1(F, Fs) after _ = file:close(F) end; @@ -395,12 +390,18 @@ dff(Name, Fs) when is_list(Name) -> {error,{badopen,Reason}} end. +dff_1(File, Fs) -> + lists:foreach(fun(Mfa) -> + disassemble_function(File, Mfa), + file:write(File, "\n") + end, Fs). + disassemble_function(File, {_,_,_}=MFA) -> cont_dis(File, erts_debug:disassemble(MFA), MFA). cont_dis(_, false, _) -> ok; cont_dis(File, {Addr,Str,MFA}, MFA) -> - io:put_chars(File, binary_to_list(Str)), + ok = file:write(File, Str), cont_dis(File, erts_debug:disassemble(Addr), MFA); cont_dis(_, {_,_,_}, _) -> ok. |