aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-05-27 04:21:20 +0200
committerBjörn Gustavsson <[email protected]>2015-06-05 10:15:07 +0200
commit34e019dc29044e6f3b8d256a20f4ca83a3ac24a7 (patch)
tree4f5738e86be2b400f4d286d311106ba6a6157839
parent73441d91d3f229f2046fa8ca917782c0a720c6e3 (diff)
downloadotp-34e019dc29044e6f3b8d256a20f4ca83a3ac24a7.tar.gz
otp-34e019dc29044e6f3b8d256a20f4ca83a3ac24a7.tar.bz2
otp-34e019dc29044e6f3b8d256a20f4ca83a3ac24a7.zip
Clean up rpc_SUITE:call_benchmark/1
The call_benchmark/1 test case is supposed to return a comment about the number of RPC calls per second, but the return value from the function that produces the comment (do_call_benchmark/4) is ignored. The test case is essentially useless except as a smoke test. Simplify the test case and correct the showing of the number of RPC calls per second, as well as eliminate the use of erlang:now/0.
-rw-r--r--lib/kernel/test/rpc_SUITE.erl41
1 files changed, 21 insertions, 20 deletions
diff --git a/lib/kernel/test/rpc_SUITE.erl b/lib/kernel/test/rpc_SUITE.erl
index 7adef49014..867b448b36 100644
--- a/lib/kernel/test/rpc_SUITE.erl
+++ b/lib/kernel/test/rpc_SUITE.erl
@@ -456,32 +456,33 @@ called_throws(Config) when is_list(Config) ->
call_benchmark(Config) when is_list(Config) ->
Timetrap = ?t:timetrap(?t:seconds(120)),
- ?line PA = filename:dirname(code:which(?MODULE)),
- ?line {ok, Node} = ?t:start_node(rpc_SUITE_call_benchmark, slave,
- [{args, "-pa " ++ PA}]),
+ PA = filename:dirname(code:which(?MODULE)),
+ {ok, Node} = ?t:start_node(rpc_SUITE_call_benchmark, slave,
+ [{args, "-pa " ++ PA}]),
Iter = case erlang:system_info(modified_timing_level) of
undefined -> 10000;
- _ -> 500 %Moified timing - spawn is slower
+ _ -> 500 %Modified timing - spawn is slower
end,
- ?line do_call_benchmark(Node, Iter),
+ Res = do_call_benchmark(Node, Iter),
+ ?t:stop_node(Node),
?t:timetrap_cancel(Timetrap),
- ok.
+ Res.
do_call_benchmark(Node, M) when is_integer(M), M > 0 ->
- do_call_benchmark(Node, erlang:now(), 0, M).
-
-do_call_benchmark(Node, {A,B,C}, M, M) ->
- ?line {D,E,F} = erlang:now(),
- ?line T = float(D-A)*1000000.0 + float(E-B) + float(F-C)*0.000001,
- ?line Q = 3.0 * float(M) / T,
- ?line ?t:stop_node(Node),
- {comment,
- lists:flatten([float_to_list(Q)," RPC calls per second"])};
-do_call_benchmark(Node, Then, I, M) ->
- ?line Node = rpc:call(Node, erlang, node, []),
- ?line _ = rpc:call(Node, erlang, whereis, [rex]),
- ?line 3 = rpc:call(Node, erlang, '+', [1,2]),
- ?line do_call_benchmark(Node, Then, I+1, M).
+ {Micros,ok} = timer:tc(fun() ->
+ do_call_benchmark(Node, 0, M)
+ end),
+ Calls = 3*M,
+ S = io_lib:format("~p RPC calls/second", [Calls*1000000 div Micros]),
+ {comment,lists:flatten(S)}.
+
+do_call_benchmark(_Node, M, M) ->
+ ok;
+do_call_benchmark(Node, I, M) ->
+ Node = rpc:call(Node, erlang, node, []),
+ _ = rpc:call(Node, erlang, whereis, [rex]),
+ 3 = rpc:call(Node, erlang, '+', [1,2]),
+ do_call_benchmark(Node, I+1, M).
async_call(Config) when is_list(Config) ->
Dog = ?t:timetrap(?t:seconds(120)),