aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/base/diameter_lib.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/diameter/src/base/diameter_lib.erl')
-rw-r--r--lib/diameter/src/base/diameter_lib.erl40
1 files changed, 6 insertions, 34 deletions
diff --git a/lib/diameter/src/base/diameter_lib.erl b/lib/diameter/src/base/diameter_lib.erl
index 3f327f3653..6a94e32b0e 100644
--- a/lib/diameter/src/base/diameter_lib.erl
+++ b/lib/diameter/src/base/diameter_lib.erl
@@ -102,8 +102,7 @@ fmt(T) ->
%% ---------------------------------------------------------------------------
-type timestamp() :: {non_neg_integer(), 0..999999, 0..999999}.
--type now() :: integer() %% monotonic time
- | timestamp().
+-type now() :: timestamp().
-spec now()
-> now().
@@ -112,11 +111,7 @@ fmt(T) ->
%% otherwise.
now() ->
- try
- erlang:monotonic_time()
- catch
- error: undef -> erlang:now()
- end.
+ erlang:now().
%% ---------------------------------------------------------------------------
%% # timestamp/1
@@ -126,15 +121,7 @@ now() ->
-> timestamp().
timestamp({_,_,_} = T) -> %% erlang:now()
- T;
-
-timestamp(MonoT) -> %% monotonic time
- MicroSecs = monotonic_to_microseconds(MonoT + erlang:time_offset()),
- Secs = MicroSecs div 1000000,
- {Secs div 1000000, Secs rem 1000000, MicroSecs rem 1000000}.
-
-monotonic_to_microseconds(MonoT) ->
- erlang:convert_time_unit(MonoT, native, micro_seconds).
+ T.
%% ---------------------------------------------------------------------------
%% # now_diff/1
@@ -162,10 +149,7 @@ now_diff(Time) ->
when MicroSecs :: non_neg_integer().
micro_diff({_,_,_} = T0) ->
- timer:now_diff(erlang:now(), T0);
-
-micro_diff(T0) -> %% monotonic time
- monotonic_to_microseconds(erlang:monotonic_time() - T0).
+ timer:now_diff(erlang:now(), T0).
%% ---------------------------------------------------------------------------
%% # micro_diff/2
@@ -175,12 +159,8 @@ micro_diff(T0) -> %% monotonic time
-> MicroSecs
when MicroSecs :: non_neg_integer().
-micro_diff(T1, T0)
- when is_integer(T1), is_integer(T0) -> %% monotonic time
- monotonic_to_microseconds(T1 - T0);
-
micro_diff(T1, T0) -> %% at least one erlang:now()
- timer:now_diff(timestamp(T1), timestamp(T0)).
+ timer:now_diff(T1, T0).
%% ---------------------------------------------------------------------------
%% # time/1
@@ -219,15 +199,7 @@ time(Micro) -> %% elapsed time
seed() ->
T = now(),
- {timestamp(T), seed(T)}.
-
-%% seed/1
-
-seed({_,_,_} = T) ->
- T;
-
-seed(T) -> %% monotonic time
- {erlang:phash2(node()), T, erlang:unique_integer()}.
+ {T, T}.
%% ---------------------------------------------------------------------------
%% # eval/1