aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/base/diameter_lib.erl
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2015-03-22 09:45:22 +0100
committerAnders Svensson <[email protected]>2015-03-22 09:45:22 +0100
commitd8d522251a7b8a1b3a69718e9328eb62acc9e22c (patch)
tree16cd7b5498b2da1de23647ae1fb2c9d8a65b6f37 /lib/diameter/src/base/diameter_lib.erl
parentc8859fae10da567e13a0090c6cc04f4de634dc73 (diff)
parent90f97f3e17acb63bfae2e07646cfaf098ed3dbdd (diff)
downloadotp-d8d522251a7b8a1b3a69718e9328eb62acc9e22c.tar.gz
otp-d8d522251a7b8a1b3a69718e9328eb62acc9e22c.tar.bz2
otp-d8d522251a7b8a1b3a69718e9328eb62acc9e22c.zip
Merge branch 'maint'
Diffstat (limited to 'lib/diameter/src/base/diameter_lib.erl')
-rw-r--r--lib/diameter/src/base/diameter_lib.erl15
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/diameter/src/base/diameter_lib.erl b/lib/diameter/src/base/diameter_lib.erl
index b9defbd077..51d203d722 100644
--- a/lib/diameter/src/base/diameter_lib.erl
+++ b/lib/diameter/src/base/diameter_lib.erl
@@ -130,12 +130,13 @@ timestamp({_,_,_} = T) -> %% erlang:now()
T;
timestamp(MonoT) -> %% monotonic time
- MicroSecs = erlang:convert_time_resolution(MonoT + erlang:time_offset(),
- erlang:time_resolution(),
- 1000000),
+ 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).
+
%% ---------------------------------------------------------------------------
%% # now_diff/1
%% ---------------------------------------------------------------------------
@@ -165,9 +166,7 @@ micro_diff({_,_,_} = T0) ->
timer:now_diff(erlang:now(), T0);
micro_diff(T0) -> %% monotonic time
- erlang:convert_time_resolution(erlang:monotonic_time() - T0,
- erlang:time_resolution(),
- 1000000).
+ monotonic_to_microseconds(erlang:monotonic_time() - T0).
%% ---------------------------------------------------------------------------
%% # micro_diff/2
@@ -179,9 +178,7 @@ micro_diff(T0) -> %% monotonic time
micro_diff(T1, T0)
when is_integer(T1), is_integer(T0) -> %% monotonic time
- erlang:convert_time_resolution(T1 - T0,
- erlang:time_resolution(),
- 1000000);
+ monotonic_to_microseconds(T1 - T0);
micro_diff(T1, T0) -> %% at least one erlang:now()
timer:now_diff(timestamp(T1), timestamp(T0)).