File 1140-Use-monotonic_time-1-instead-of-now-0.patch of Package erlang

From e7473f6810b249d1115361f005fb8b44fe59f474 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= <egil@erlang.org>
Date: Wed, 16 Mar 2016 18:36:18 +0100
Subject: [PATCH] Use monotonic_time/1 instead of now/0

---
 lib/percept/src/percept.erl        |  6 +++---
 lib/percept/test/percept_SUITE.erl | 14 ++++++--------
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/lib/percept/src/percept.erl b/lib/percept/src/percept.erl
index badb3f3..f1a2002 100644
--- a/lib/percept/src/percept.erl
+++ b/lib/percept/src/percept.erl
@@ -226,7 +226,7 @@ stop_webserver(Port) ->
 
 parse_and_insert(Filename, DB) ->
     io:format("Parsing: ~p ~n", [Filename]),
-    T0 = erlang:now(),
+    T0 = erlang:monotonic_time(milli_seconds),
     Pid = dbg:trace_client(file, Filename, mk_trace_parser(self())),
     Ref = erlang:monitor(process, Pid), 
     parse_and_insert_loop(Filename, Pid, Ref, DB, T0).
@@ -239,8 +239,8 @@ parse_and_insert_loop(Filename, Pid, Ref, DB, T0) ->
     	{parse_complete, {Pid, Count}} ->
 	    receive {'DOWN', Ref, process, Pid, normal} -> ok after 0 -> ok end,
 	    DB ! {action, consolidate},
-	    T1 = erlang:now(),
-	    io:format("Parsed ~p entries in ~p s.~n", [Count, ?seconds(T1, T0)]),
+            T1 = erlang:monotonic_time(milli_seconds),
+	    io:format("Parsed ~w entries in ~w ms.~n", [Count, T1 - T0]),
     	    io:format("    ~p created processes.~n", [length(percept_db:select({information, procs}))]),
      	    io:format("    ~p opened ports.~n", [length(percept_db:select({information, ports}))]),
 	    ok;
diff --git a/lib/percept/test/percept_SUITE.erl b/lib/percept/test/percept_SUITE.erl
index 06d6263..afb8bbd 100644
--- a/lib/percept/test/percept_SUITE.erl
+++ b/lib/percept/test/percept_SUITE.erl
@@ -116,11 +116,10 @@ analyze(Config) when is_list(Config) ->
     Begin = processes(),
     Path = ?config(data_dir, Config),
     File = filename:join([Path,"profile_test.dat"]),
-    T0 = erlang:now(),
+    T0 = erlang:monotonic_time(milli_seconds),
     ?line ok = percept:analyze(File),
-    T1 = erlang:now(),
-    Secs = timer:now_diff(T1,T0)/1000000,
-    io:format("percept:analyze/1 took ~.2f s.~n", [Secs]),
+    T1 = erlang:monotonic_time(milli_seconds),
+    io:format("percept:analyze/1 took ~w ms.~n", [T1 - T0]),
     ?line {stopped, _} = percept_db:stop(),
     print_remainers(remainers(Begin, processes())),
     ok.
@@ -133,11 +132,10 @@ analyze_dist(Config) when is_list(Config) ->
     Begin = processes(),
     Path = ?config(data_dir, Config),
     File = filename:join([Path,"ipc-dist.dat"]),
-    T0 = erlang:now(),
+    T0 = erlang:monotonic_time(milli_seconds),
     ?line ok = percept:analyze(File),
-    T1 = erlang:now(),
-    Secs = timer:now_diff(T1,T0)/1000000,
-    io:format("percept:analyze/1 took ~.2f s.~n", [Secs]),
+    T1 = erlang:monotonic_time(milli_seconds),
+    io:format("percept:analyze/1 took ~w ms.~n", [T1 - T0]),
     ?line {stopped, _} = percept_db:stop(),
     print_remainers(remainers(Begin, processes())),
     ok.
-- 
2.1.4

openSUSE Build Service is sponsored by