Przeglądaj źródła

ft: test

master
lijie 2 lat temu
rodzic
commit
b76b93ff83
1 zmienionych plików z 86 dodań i 1 usunięć
  1. +86
    -1
      src/testCase/funTest.erl

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

@ -14,7 +14,7 @@ test2(A) ->
Fun1(A, A, A, A, A, Fun1).
test3(A) ->
[O * 2 || O <- A],
_ = [O * 2 || O <- A],
ok.
-define(types, [1, 1.1, [], [1], {1}, #{}, <<"123">>, self()]).
@ -66,6 +66,91 @@ ok(N) ->
test(A) ->
?IIF(lists:keyfind(a, 1, A), false, none, {_, V}, V).
ams1(A) -> ok.
ams2(A) -> fun() -> A end.
amf1(0, A, B, C, _) -> ok;
amf1(N, A, B, C, _) ->
amf1(N - 1, A, B, C, 1) .
amf2(0, A, B, C, _) -> ok;
amf2(N, A, B, C, _) ->
Fun = fun(One1) -> X = (One1 * A * B * C), Y = B-C, Z = X / Y, Z end,
amf2(N - 1, A, B, C, Fun).
ok1(0, A, _) ->
ok;
ok1(N, A, _) ->
IS = A == 1 orelse A == 2 orelse A == 3 orelse A == 4 orelse A == 5 orelse A == 6,
ok1(N - 1, A, IS).
ok2(0, A, _) ->
ok;
ok2(N, A, _) ->
IS = lists:member(A, [1, 2, 3, 4, 5, 6]),
ok2(N - 1, A, IS).
test2() ->
{Time, _} = timer:tc(?MODULE, compare, [100000000]),
io:format("Time : ~p~n", [Time]),
{Time2, _} = timer:tc(?MODULE, compare2, [100000000]),
io:format("Time2: ~p~n", [Time2]).
compare(0) ->
ok;
compare(N) when N =/= (N-1) orelse N =:= N ->
compare(N - 1).
compare2(0) ->
ok;
compare2(N) when N /= (N-1) orelse N == N ->
compare(N - 1).
timer(_, _) ->
I = atomics:add_get(persistent_term:get(cnt), 1, 1),
io:format("IMY******* ~p~n", [I]) ,
case I of
1000000 ->
io:format("end time ~p ~n", [erlang:system_time(millisecond)]);
_ ->
ignore
end,
ok.
test(N, Time) ->
io:format("start time1 ~p ~n", [erlang:system_time(millisecond)]),
persistent_term:put(cnt, atomics:new(1, [])),
gTimer:startWork(16),
doTest(N, Time).
doTest(0, Time) ->
io:format("start time2 ~p ~n", [erlang:system_time(millisecond)]),
gTimer:setTimer(rand:uniform(Time), {?MODULE, timer, []});
doTest(N, Time) ->
gTimer:setTimer(rand:uniform(Time), {?MODULE, timer, []}),
doTest(N - 1, Time).
timer(_) ->
%io:format("IMY******* ~p~n", [I]) ,
% case I of
% 1000000 ->
% io:format("end time ~p ~n", [erlang:system_time(millisecond)]);
% _ ->
% ignore
% end,
ok.
testBBB(Bin1) ->
Bin2 = term_to_binary(Bin1),
Bin = <<1:1, Bin2/binary>>,
io:format("IMY**********testBBB ~p size ~p ~p ~p ~n", [self(), bit_size(Bin), erts_internal:term_type(Bin), binaryAddr:getBinAddr(Bin2)]),
spawn(?MODULE, tt, [Bin]).
tt(B) ->
<<_A:1, Bin/binary>> = B,
io:format("IMY**********ttxxxxx ~p size ~p ~p ~p ~n", [self(), bit_size(B), erts_internal:term_type(B), binaryAddr:getBinAddr(Bin)]).

Ładowanie…
Anuluj
Zapisz