From 7a9895ee2a13e62270cbd0c34902fc740008223a Mon Sep 17 00:00:00 2001 From: SisMaker <156736github> Date: Wed, 29 Jun 2022 23:03:19 +0800 Subject: [PATCH 1/3] =?UTF-8?q?ft:=20=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/compile/utKvsToBeam.erl | 2 +- src/compile/utStrToBeam.erl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compile/utKvsToBeam.erl b/src/compile/utKvsToBeam.erl index 6f84724..13c6882 100644 --- a/src/compile/utKvsToBeam.erl +++ b/src/compile/utKvsToBeam.erl @@ -13,7 +13,7 @@ load(Module, KVs) -> Forms = forms(Module, KVs), {ok, Module, Bin} = compile:forms(Forms), code:soft_purge(Module), - {module, Module} = code:load_binary(Module, atom_to_list(Module), Bin), + {module, Module} = code:load_binary(Module, [], Bin), ok. forms(Module, KVs) -> diff --git a/src/compile/utStrToBeam.erl b/src/compile/utStrToBeam.erl index eb61539..3c229ce 100644 --- a/src/compile/utStrToBeam.erl +++ b/src/compile/utStrToBeam.erl @@ -8,4 +8,4 @@ load(Module, Export, Str) -> {ok, Forms} = erl_parse:parse_form(Tokens), NewForms = [{attribute, 1, module, Module}, {attribute, 2, export, Export}, Forms], {ok, _, Binary} = compile:forms(NewForms), - code:load_binary(Module, "", Binary). + code:load_binary(Module, [], Binary). From 0a09dd1881033153f4ad9827629c1b39790e52aa Mon Sep 17 00:00:00 2001 From: lijie <1713699517@qq.com> Date: Mon, 4 Jul 2022 17:06:29 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fx:=20=E9=94=99=E8=AF=AF=E6=8B=BC=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/docs/erlang/erlang进程.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/docs/erlang/erlang进程.md b/src/docs/erlang/erlang进程.md index 14c836f..6612575 100644 --- a/src/docs/erlang/erlang进程.md +++ b/src/docs/erlang/erlang进程.md @@ -132,7 +132,7 @@ end demonitor(MonitorRef, OptionList) 监视器与link不同的是它是单向式观察一些进程终止,各个监视器通过Erlang的引用相互区分,是调用monitor返回的,具有唯一性, 而且A进程可以设置多个对B进程的监视器,每一个通过不同的引用区分。 - 当被监视的进程终止时,一条格式{'Down',Reference, process, Pid, Reason}的消息会被发给监视此进程的进程 + 当被监视的进程终止时,一条格式{'DOWN',Reference, process, Pid, Reason}的消息会被发给监视此进程的进程 调用erlang:demonitor(Reference)可以移除监视器, 调用erlang:demonitor(Reference,[flush])可以让该监视进程邮箱中所有与Reference对应的{'DOWN', Reference,process,Pid,Reason} 的消息被冲刷掉。 From b76b93ff834d17bf0c56f355e996388483d4838b Mon Sep 17 00:00:00 2001 From: lijie <1713699517@qq.com> Date: Tue, 16 Aug 2022 17:05:12 +0800 Subject: [PATCH 3/3] ft: test --- src/testCase/funTest.erl | 87 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/src/testCase/funTest.erl b/src/testCase/funTest.erl index 084ccec..9baaca6 100644 --- a/src/testCase/funTest.erl +++ b/src/testCase/funTest.erl @@ -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)]).