diff options
author | Rickard Green <[email protected]> | 2015-03-29 01:29:23 +0100 |
---|---|---|
committer | Rickard Green <[email protected]> | 2015-05-06 15:58:32 +0200 |
commit | f0d51083a6cda851ed60578a7679e20b1fe5678a (patch) | |
tree | 5a226fc49118adf9b42f4594c843082d9328a03f /erts/emulator/test/after_SUITE.erl | |
parent | e135070d4c7135228756e6a43dbdd638b565a499 (diff) | |
download | otp-f0d51083a6cda851ed60578a7679e20b1fe5678a.tar.gz otp-f0d51083a6cda851ed60578a7679e20b1fe5678a.tar.bz2 otp-f0d51083a6cda851ed60578a7679e20b1fe5678a.zip |
Replace erlang:now() usage in emulator suite
Diffstat (limited to 'erts/emulator/test/after_SUITE.erl')
-rw-r--r-- | erts/emulator/test/after_SUITE.erl | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/erts/emulator/test/after_SUITE.erl b/erts/emulator/test/after_SUITE.erl index 7cc329cc69..699a1436ce 100644 --- a/erts/emulator/test/after_SUITE.erl +++ b/erts/emulator/test/after_SUITE.erl @@ -70,30 +70,23 @@ end_per_testcase(_Func, Config) -> t_after(Config) when is_list(Config) -> ?line spawn(fun frequent_process/0), ?line Period = test_server:minutes(1), - ?line Before = erlang:now(), + ?line Before = erlang:monotonic_time(), receive after Period -> - ?line After = erlang:now(), + ?line After = erlang:monotonic_time(), ?line report(Period, Before, After) end. - report(Period, Before, After) -> - ?line Elapsed = (element(1, After)*1000000000 - +element(2, After)*1000 - +element(3, After) div 1000) - - (element(1,Before)*1000000000 - + element(2,Before)*1000 + element(3,Before) div 1000), - ?line case Elapsed*100 / Period of - Percent when Percent > 100.10 -> - ?line test_server:fail({too_inaccurate, Percent}); - Percent when Percent < 100.0 -> - ?line test_server:fail({too_early, Percent}); - Percent -> - ?line Comment = io_lib:format("Elapsed/expected: ~.2f %", - [Percent]), - {comment, lists:flatten(Comment)} - end. + case erlang:convert_time_unit(After - Before, native, 100*1000) / Period of + Percent when Percent > 100.10 -> + test_server:fail({too_inaccurate, Percent}); + Percent when Percent < 100.0 -> + test_server:fail({too_early, Percent}); + Percent -> + Comment = io_lib:format("Elapsed/expected: ~.2f %", [Percent]), + {comment, lists:flatten(Comment)} + end. frequent_process() -> receive |