Last active
July 7, 2023 08:19
-
-
Save kingluo/6e5245692b76dda5ecd4 to your computer and use it in GitHub Desktop.
erlang noshell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ erlc processes.erl | |
$ erl -noshell -s processes test -s init stop | |
the max processes is 262144 | |
the proecess time is 2.0:3.57 | |
$ erl -noshell -s processes test2 100000 -s init stop | |
the max processes is 262144 | |
{"init terminating in do_boot",{system_limit,[{erlang,spawn,[erlang,apply,[#Fun<processes.2.26012808>,[]]],[]},{erlang,spawn,1,[]},{processes,for,3,[{file,"processes.erl"},{line,24}]},{processes,for,3,[{file,"processes.erl"},{line,24}]},{processes,max,1,[{file,"processes.erl"},{line,10}]},{init,start_it,1,[]},{init,start_em,1,[]}]}} | |
# program freeze here... | |
# Ctrl+C not work | |
# Instead, press Ctrl+Z, then pkill -9 beam.smp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(processes). | |
-compile(export_all). | |
%%-export(export_all). | |
max(N)-> | |
Max=erlang:system_info(process_limit), | |
io:format("the max processes is ~p ~n",[Max]), | |
statistics(runtime), | |
statistics(wall_clock), | |
L=for(1,N,fun()->spawn(fun()->wait() end) end), | |
{_,Time1}=statistics(runtime), | |
{_,Time2}=statistics(wall_clock), | |
lists:foreach(fun(Pid)->Pid!die end,L), | |
U1=Time1*1000/N, | |
U2=Time2*1000/N, | |
io:format("the proecess time is ~p:~p ~n",[U1,U2]). | |
wait()-> | |
receive | |
die->void | |
end. | |
for(N,N,F)->[F()]; | |
for(I,N,F)->[F()|for(I+1,N,F)]. | |
test()-> | |
max(100000). | |
test2(N)-> | |
max(N). | |
main([])-> | |
max(100000). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment