diff options
author | Björn-Egil Dahlberg <[email protected]> | 2010-11-30 15:21:45 +0100 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2010-11-30 15:21:45 +0100 |
commit | 5941263574cf7aa31450b288d6d2476bf2486613 (patch) | |
tree | e01da9eff1d08c46395e6a058bcbbbb69ca8d454 /lib/tools/src | |
parent | 4e93980963cda309011a49baddc44d98b421822b (diff) | |
download | otp-5941263574cf7aa31450b288d6d2476bf2486613.tar.gz otp-5941263574cf7aa31450b288d6d2476bf2486613.tar.bz2 otp-5941263574cf7aa31450b288d6d2476bf2486613.zip |
eprof: fix badarith exception on divide
Error caused by low resolution timers.
Diffstat (limited to 'lib/tools/src')
-rw-r--r-- | lib/tools/src/eprof.erl | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/tools/src/eprof.erl b/lib/tools/src/eprof.erl index 8e5c0ec46b..87fdc1fa34 100644 --- a/lib/tools/src/eprof.erl +++ b/lib/tools/src/eprof.erl @@ -136,7 +136,7 @@ handle_call({analyze, procs, Opts}, _, #state{ bpd = #bpd{ p = Ps, us = Tus} = B lists:foreach(fun ({Pid, Mfas}) -> {Pn, Pus} = sum_bp_total_n_us(Mfas), - format(Fd, "~n****** Process ~w -- ~s % of profiled time *** ~n", [Pid, s("~.2f", [100.0*(Pus/Tus)])]), + format(Fd, "~n****** Process ~w -- ~s % of profiled time *** ~n", [Pid, s("~.2f", [100.0*divide(Pus,Tus)])]), print_bp_mfa(Mfas, {Pn,Pus}, Fd, Opts), ok end, gb_trees:to_list(Ps)), @@ -443,8 +443,8 @@ string_bp_mfa([{Mfa, {Count, Time}}|Mfas], Tus, {MfaW, CountW, PercW, TimeW, TpC Smfa = s(Mfa), Scount = s(Count), Stime = s(Time), - Sperc = s("~.2f", [100*(Time/Tus)]), - Stpc = s("~.2f", [Time/Count]), + Sperc = s("~.2f", [100*divide(Time,Tus)]), + Stpc = s("~.2f", [divide(Time,Count)]), string_bp_mfa(Mfas, Tus, { erlang:max(MfaW, length(Smfa)), @@ -484,3 +484,6 @@ format(Fd, Format, Strings) -> io:format(Fd, Format, Strings), io:format(Format, Strings), ok. + +divide(_,0) -> 0.0; +divide(T,N) -> T/N. |