aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-04-20 14:59:19 +0200
committerBjörn Gustavsson <[email protected]>2015-04-20 15:33:44 +0200
commit740ecf83a6cec93fc40a3ced1f7d8825a39516e4 (patch)
treeeb12609cfaf679e12f1ab974775687718304adb0 /lib/compiler
parentd927209aa36fe370eb4ecf0a081923b0b951458b (diff)
downloadotp-740ecf83a6cec93fc40a3ced1f7d8825a39516e4.tar.gz
otp-740ecf83a6cec93fc40a3ced1f7d8825a39516e4.tar.bz2
otp-740ecf83a6cec93fc40a3ced1f7d8825a39516e4.zip
compile: Teach 'time' option to show three significant decimals
The 'time' option currently uses statistics(runtime) to measure execution times. Typically, statistics(runtime) only returns result with two significant figures. Use the new erlang:monotonic_time/0 function to get three significant figures.
Diffstat (limited to 'lib/compiler')
-rw-r--r--lib/compiler/src/compile.erl11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index c45c9a1a29..635d322cc9 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -320,15 +320,14 @@ fold_comp([{Name,Pass}|Ps], Run, St0) ->
fold_comp([], _Run, St) -> {ok,St}.
run_tc({Name,Fun}, St) ->
- Before0 = statistics(runtime),
+ T1 = erlang:monotonic_time(),
Val = (catch Fun(St)),
- After0 = statistics(runtime),
- {Before_c, _} = Before0,
- {After_c, _} = After0,
+ T2 = erlang:monotonic_time(),
+ Elapsed = erlang:convert_time_unit(T2 - T1, native, milli_seconds),
Mem0 = erts_debug:flat_size(Val)*erlang:system_info(wordsize),
Mem = lists:flatten(io_lib:format("~.1f kB", [Mem0/1024])),
- io:format(" ~-30s: ~10.2f s ~12s\n",
- [Name,(After_c-Before_c) / 1000,Mem]),
+ io:format(" ~-30s: ~10.3f s ~12s\n",
+ [Name,Elapsed/1000,Mem]),
Val.
comp_ret_ok(#compile{code=Code,warnings=Warn0,module=Mod,options=Opts}=St) ->