内存: (a@localhost)25> lists:sublist(lists:reverse(lists:sort(lists:map(fun(P)->case erlang:process_info(P,memory) of {_,M} -> {M,P}; _->{0,P} end end,processes()))),5). [{831280,<0.25.0>}, {426448,<0.31.0>}, {263856,<0.80.0>}, {263792,<0.3.0>}, {263752,<0.96.0>}] (a@localhost)26>
消息队列: (a@localhost)26> lists:sublist(lists:reverse(lists:sort(lists:map(fun(P)->case erlang:process_info(P,message_queue_len) of {_,MQ} -> {MQ,P}; _->{0,P} end end,processes()))),5). [{0,<0.96.0>}, {0,<0.80.0>}, {0,<0.79.0>}, {0,<0.78.0>}, {0,<0.77.0>}] (a@localhost)27>
用代码检测base64:encode的效率
1 2 3 4 5 6 7 8 9 10 11
(a@localhost)20> F2 = fun(C)-> A = crypto:rand_bytes(100*1024), T1=now(),lists:map(fun(_)-> catch base64:encode(A) end, lists:seq(1,C)),T2=now(),io:format("~p time use ~.2f ms ~n",[C,timer:now_diff(T2,T1)/1000]) end. #Fun<erl_eval.6.90072148> (a@localhost)22> F2(10). 10 time use 166.91 ms ok (a@localhost)23> F2(100). 100 time use 1612.59 ms ok (a@localhost)24> F2(1000). 1000 time use 16845.46 ms ok
如何用kill取dump文件和如何查看dump文件
1 2 3 4 5 6 7 8 9 10
kill -s USR1 $pid
查看dump文件操作,进入erlang shell,输入: (bb@lghdeMacBook)1> webtool:start(). WebTool is available at http://localhost:8888/ Or http://127.0.0.1:8888/ {ok,<0.42.0>} (bb@lghdeMacBook)2>