Browse Source

ft: 测试用例修改

master
SisMaker 3 years ago
parent
commit
a1a0821d28
3 changed files with 67 additions and 4 deletions
  1. +46
    -0
      test/ping3.erl
  2. +4
    -4
      test/pong2.erl
  3. +17
    -0
      test/pong3.erl

+ 46
- 0
test/ping3.erl View File

@ -0,0 +1,46 @@
-module(ping3).
-compile([export_all, nowarn_export_all]).
call(N) ->
{ok, Pid} = pong3:start(),
StartTime = erlang:system_time(nanosecond),
doCall(N, Pid, StartTime).
doCall(0, Pid, StartTime) ->
EndTime = erlang:system_time(nanosecond),
exit(Pid, kill),
io:format("call3 over use time: ~p ns~n", [EndTime - StartTime]);
doCall(N, Pid, StartTime) ->
gen_apu:call(Pid, ping),
doCall(N - 1, Pid, StartTime).
send(N) ->
{ok, Pid} = pong3:start(),
StartTime = erlang:system_time(nanosecond),
doSend(N, Pid, StartTime).
doSend(0, Pid, StartTime) ->
% Ret = gen_apu:call(Pid, ping),
Ret = 1,
EndTime = erlang:system_time(nanosecond),
exit(Pid, kill),
io:format("send2 over use time: ~p ~p ns~n", [Ret, EndTime - StartTime]);
doSend(N, Pid, StartTime) ->
gen_apu:send(Pid, ping),
doSend(N - 1, Pid, StartTime).
cast(N) ->
{ok, Pid} = pong3:start(),
StartTime = erlang:system_time(nanosecond),
doCast(N, Pid, StartTime).
doCast(0, Pid, StartTime) ->
%Ret = gen_apu:call(Pid, ping),
Ret = 1,
EndTime = erlang:system_time(nanosecond),
exit(Pid, kill),
io:format("cast3 over use time: ~p ~p ns~n", [Ret, EndTime - StartTime]);
doCast(N, Pid, StartTime) ->
gen_apu:cast(Pid, ping2),
doCast(N - 1, Pid, StartTime).

+ 4
- 4
test/pong2.erl View File

@ -13,8 +13,8 @@ init(_Args) ->
handleCall(ping, _State, _From) ->
{reply, pong}.
handleCast(_Msg, State) ->
{noreply, State}.
handleCast(_Msg, _State) ->
kpS.
handleInfo(_Msg, State) ->
{noreply, State}.
handleInfo(_Msg, _State) ->
kpS.

+ 17
- 0
test/pong3.erl View File

@ -0,0 +1,17 @@
-module(pong3).
-behavior(gen_apu).
-compile([export_all, nowarn_export_all]).
start() ->
gen_apu:start(?MODULE, 0, []).
init(_Args) ->
{ok, 0}.
ping(_State, _From) ->
{reply, pong}.
ping2(_State) ->
kpS.

Loading…
Cancel
Save