Przeglądaj źródła

ft: 测试用例添加

master
SisMaker 4 lat temu
rodzic
commit
d247aedb56
4 zmienionych plików z 110 dodań i 8 usunięć
  1. +77
    -0
      src/docs/erlang/tryCatch性能说明.md
  2. +8
    -3
      src/testCase/TraceMod/utStrace5.erl
  3. +1
    -1
      src/testCase/utTpfm.erl
  4. +24
    -4
      src/testCase/utTryCatchCase.erl

+ 77
- 0
src/docs/erlang/tryCatch性能说明.md Wyświetl plik

@ -0,0 +1,77 @@
# otp
otp24
## no catch
utTc:ts(10, utTryCatchCase, loopTest, [1000000, testNoCatch, normal, true]).
SumTime: 630998000(ns) 0.630998(s)
AvgTime: 63099800.0(ns) 0.0631(s)
## catch
###catch nomal
utTc:ts(10, utTryCatchCase, loopTest, [1000000, testCatch, normal, true]). MaxTime: 74246000(ns) 0.074246(s)
SumTime: 725893000(ns) 0.725893(s)
AvgTime: 72589300.0(ns) 0.072589(s)
###catch exit
utTc:ts(10, utTryCatchCase, loopTest, [1000000, testCatch, exit, true]).
SumTime: 1264673000(ns) 1.264673(s)
AvgTime: 126467300.(ns) 0.126467(s)
###catch error
utTc:ts(10, utTryCatchCase, loopTest, [1000000, testCatch, error, true]).
SumTime: 1414449300(ns) 14.144493(s)
AvgTime: 1414449300(ns) 1.414449(s)
###catch thorw
utTc:ts(10, utTryCatchCase, loopTest, [1000000, testCatch, throw, true]).
SumTime: 1229429000(ns) 1.229429(s)
AvgTime: 122942900.(ns) 0.122943(s)
## try catch(不匹配starace)
###catch nomal
utTc:ts(10, utTryCatchCase, loopTest, [1000000, testTryCatch, nomal, true]).
SumTime: 655993000(ns) 0.655993(s)
AvgTime: 65599300.0(ns) 0.065599(s)
###catch exit
utTc:ts(10, utTryCatchCase, loopTest, [1000000, testTryCatch, exit, true]).
SumTime: 1479058000(ns) 1.479058(s)
AvgTime: 147905800.(ns) 0.147906(s)
###catch error
utTc:ts(10, utTryCatchCase, loopTest, [1000000, testTryCatch, error, true]).
SumTime: 1290286000(ns) 1.290286(s)
AvgTime: 129028600.(ns) 0.129029(s)
###catch throw
utTc:ts(10, utTryCatchCase, loopTest, [1000000, testTryCatch, throw, true]).
SumTime: 1385688000(ns) 1.385688(s)
AvgTime: 138568800.(ns) 0.138569(s)
## try catch(匹配starace)
###catch nomal
utTc:ts(10, utTryCatchCase, loopTest, [1000000, testTryCatch2, normal, true]).
SumTime: 663833000(ns) 0.663833(s)
AvgTime: 66383300.0(ns) 0.066383(s)
###catch exit
utTc:ts(10, utTryCatchCase, loopTest, [1000000, testTryCatch2, exit, true]).
SumTime: 1385211400(ns) 13.852114(s)
AvgTime: 1385211400(ns) 1.385211(s)
###catch error
utTc:ts(10, utTryCatchCase, loopTest, [1000000, testTryCatch2, error, true]).
SumTime: 1370759800(ns) 13.707598(s)
AvgTime: 1370759800(ns) 1.37076(s)
###catch throw
utTc:ts(10, utTryCatchCase, loopTest, [1000000, testTryCatch2, throw, true]).
SumTime: 1386053800(ns) 13.860538(s)
AvgTime: 1386053800(ns) 1.386054(s)

+ 8
- 3
src/testCase/TraceMod/utStrace5.erl Wyświetl plik

@ -3,7 +3,12 @@
-export([test/1]).
test(Data) ->
timer:sleep(30),
utStrace1:test(Data),
{ok, Data}.
%% try catch
utTryCatchCase:makeException2(Data).
%%
%% timer:sleep(30),
%% utStrace1:test(Data),
%% {ok, Data}.

+ 1
- 1
src/testCase/utTpfm.erl Wyświetl plik

@ -586,7 +586,7 @@ etsInsert(0, Tab) ->
ets:insert(Tab, {etsT, 50000, 500, 5001}),
ok;
etsInsert(N, Tab) ->
ets:insert(Tab, {test, N, N, N + 1}),
ets:insert(Tab, {etsT, N, N, N + 1}),
etsInsert(N - 1, Tab).
-include_lib("stdlib/include/ms_transform.hrl").

+ 24
- 4
src/testCase/utTryCatchCase.erl Wyświetl plik

@ -1,7 +1,16 @@
-module(utTryCatchCase).
-compile([export_all, nowarn_unused_function, nowarn_unused_vars, nowarn_export_all]).
-export([loopTest/4, testTryCatch/1, testTryCatch/2, testCatch/1, testCatch/2, testTryCatch2/1, testTryCatch2/2]).
-export([
loopTest/4
, testTryCatch/1
, testTryCatch/2
, testCatch/1
, testCatch/2
, testTryCatch2/1
, testTryCatch2/2
]).
t1() ->
Pid = spawn(fun() -> do_t1(1) end),
@ -26,7 +35,7 @@ do_t1(N) ->
erlang:garbage_collect(),
Result = erlang:process_info(self(), [memory, garbage_collection]),
io:format("IMY************************* ~p~n ~w ~n", [N, Result]);
%io:format("IMY&&&&&&&&&&&&&&&&&&&&&&&&& ~p~n backtrace:~p~n~n", [N, erlang:process_display(self(), backtrace)]);
%io:format("IMY&&&&&&&&&&&&&&&&&&&&&&&&& ~p~n backtrace:~p~n~n", [N, erlang:process_display(self(), backtrace)]);
_ ->
ignore
end,
@ -217,7 +226,14 @@ loopTest(Times, Fun, Type, IsLoop) ->
?MODULE:Fun(Type, IsLoop),
loopTest(Times - 1, Fun, Type, IsLoop).
testTryCatch(Type) -> testTryCatch(Type, false).
testNoCatch(Type) ->
testNoCatch(Type, false).
testNoCatch(Type, _TestLoop) ->
makeException(Type).
testTryCatch(Type) ->
testTryCatch(Type, false).
testTryCatch(Type, TestLoop) ->
try
@ -230,7 +246,8 @@ testTryCatch(Type, TestLoop) ->
end
end.
testTryCatch2(Type) -> testTryCatch(Type, false).
testTryCatch2(Type) ->
testTryCatch2(Type, false).
testTryCatch2(Type, TestLoop) ->
try
@ -264,6 +281,9 @@ testCatch(Type, TestLoop) ->
makeException(Type) ->
utStrace1:test(Type).
makeException2(Type) ->
case Type of
throw -> erlang:throw(test);
error -> erlang:error(test);

Ładowanie…
Anuluj
Zapisz