- 浏览: 292506 次
- 性别:
- 来自: 北京
-
文章分类
最新评论
-
langzhe:
Mac 下用 sudo cpan Template,依然不能 ...
第一次 使用 tsung -
langzhe:
<server host='127.0.0.1' por ...
ejabberd/tsung 做压力测试万万不可忽视测试工具问题 -
dlliwei:
jabberd_register.xml 内容如下(我的ser ...
ejabberd/tsung 做压力测试万万不可忽视测试工具问题 -
dlliwei:
你好,我安装tsung后执行命令: tsung -f jabb ...
ejabberd/tsung 做压力测试万万不可忽视测试工具问题 -
bit1129:
这么复杂的一个东西,一句话说完了?
keepalive
清参考http://www.erlang.org/doc/man/eprof.html
A Time Profiling Tool for Erlang
主要API R14B 比R13B提供了更多的API
start/0,
start_profiling/1
stop_profiling/0
profile/2..
analyse/0,
total_analyse/0
log/0
23 test(N)-> 24 {ok, Epid}=eprof:start(), %启动 25 Pid = spawn(?MODULE, hello, []), 26 profiling = eprof:start_profiling([Pid]), %启动 27 test(N,Pid), %执行被分析的程序 28 eprof:stop_profiling(), 29 % eprof:analyse(), eprof:log(test), %将分析结果生成文件: 30 eprof:total_analyse(), %分析结果 31 eprof:stop(). %停止 34 test(0,_Pid) -> 35 ok; 36 test(N,Pid) -> 37 send(Pid), 38 test(N-1,Pid). 39 40 send(Pid) -> 41 Pid ! {self(),test}, 42 loop(). 51 hello() -> 52 % Pid1 = spawn(?MODULE, hello1, []), 53 % loop(), 54 t(), 55 %Pid1 ! {self(),test}, 56 receive 57 {P,test} -> 58 P ! returnok, 59 hello() 60 end. 61 t() -> 62 ok. 66 loop() -> 67 receive 68 T -> 69 T, 70 loop() 71 after 500 -> 72 timeout 73 end. ~
测试分析结果:
7> test_eprof:test(20). eprof: Starting profiling ..... eprof: Stop profiling FUNCTION CALLS TIME test_eprof:hello/0 20 80 % test_eprof:t/0 20 20 % Total time: 0.00 Measurement overhead: 0.00 stopped 8>
注意此方法的位置:是在analyse/0和total_analyse前面。否则日志里面没有数据
Types:
File = atom() | string()
This function ensures that the results displayed by analyse/0 and total_analyse/0 are printed both to the file File and the screen
(1)eprof:start_profiling([self()]),分析结果无法搜集到chat:handle_info chat:handle_cast chat:handle_call (2)eprof:start_profiling([chat]), 分析结果无法搜集到chat:handle_info chat:handle_cast 出现问题的原因: Sending a message (handled by handle_info) or doing a cast (handled by handle_cast) are both async. You are stopping the profiler too early.Changing the order to do the async operations first, then the sync one should assure that all the requests have been handled before you stop eprof我添加seelp试过,问题搞定! -module(chat). -compile(export_all). %-behaviour(gen_server). start(N) -> start_link(), eprof:start(), eprof:start_profiling([self()]), test(N), testcast(), test(), eprof:stop_profiling(), eprof:log(chat), eprof:analyse(), eprof:total_analyse(). test(N)-> gen_server:call(?MODULE, {test,N}). test()-> chat ! {test,1}. testcast() -> gen_server:cast(?MODULE,castttt). start_link() -> gen_server:start_link({local,?MODULE},?MODULE,[],[]). init([]) -> {ok, {}}. handle_cast(Msg,State) -> tttt(), io:format("cast=~p~n",[Msg]), {noreply,State}. handle_call({test,Number},From, State) when is_number(Number) -> Reply = Number+1, {reply, Reply,State}; handle_call(_,From, State) -> Reply = numerror, {reply, Reply,State}. handle_info(Ino,State) -> tttt(), io:format("info=~p~n",[Ino]), {noreply,State}. tttt() -> ok.
- test.zip (263 Bytes)
- 下载次数: 12
发表评论
-
分析 mnesia 索引慢的问题,结果出乎意料.
2015-12-15 15:09 1409分析 mnesia 索引慢的 ... -
keepalive
2014-08-12 17:30 1311{keepalive, Boolean}(TCP/IP so ... -
erlang 手动回收内存
2014-01-20 16:39 1663%%% Garbage collection may ta ... -
Erlang内存分布
2014-01-17 20:18 2067此文来自:https://blog.heroku.com/ ... -
flush 方法小用和pid()方法
2014-01-08 19:23 10761> flush(). ok 2> Pi ... -
Erlang bit语法入门-1
2013-05-14 12:18 923Erlang bit语法入门 1> Red ... -
++操作与lists:concat操作比较 (lists:concat运算结果)
2013-04-11 14:53 1205测试环境 Linux jason-lxw 3.2.0-3 ... -
解决错误src/rabbit_networking.erl:49: type hostname() undefined
2013-02-21 12:31 1072使用 make USE_SPECS=false 参数编译 ... -
我的第一个escript
2013-02-21 11:38 9871 #!/usr/bin/env escript ... -
不要忽略任何一个错误提示,更要找到原因linked websocket controlling loop crashed with reason: kille
2013-02-20 14:29 1134开发程序的时候,好几次都看到后台打出下面的错误日志。 ... -
ets:update_counter实现数字循环
2013-01-18 17:33 2073首先初始化为1 ets:insert(?MODULE, ... -
Re 从表头合理取出host
2013-01-17 15:46 935hd(re:split(Host, ":" ... -
测试 erlang:monitor
2012-11-28 18:59 995测试代码 1 -module(testmonito ... -
lcnt工具
2012-11-20 13:54 767lcnt工具可以统计虚拟机内部的锁使用次数和冲突次数指导系统的 ... -
数字前面补零
2012-11-16 17:04 821lists:flatten(io_lib:fwrite(&qu ... -
get uuid
2012-11-02 10:56 12581、 string:strip(os:cmd("u ... -
apns推送
2012-10-26 11:51 1293%%%------------- ... -
make rel Command 'generate' not understood or not applicable
2012-09-21 11:14 1977今天 编译riak时遇到了 Command 'gene ... -
Did you notice the concept of "save queue"?
2012-09-14 17:36 639Did you notice the concept o ... -
Erlang截取中文问题
2012-08-20 15:06 1546NewSummary = xmerl_ucs:to_utf8( ...
相关推荐
**Erlang——性能分析工具之eprof** 在Erlang编程中,优化代码性能是提高系统效率的关键环节。...通过深入学习eprof的使用和源码分析,我们可以更好地理解和优化Erlang程序,从而实现更高效的并发计算。
Eprof作为一个精细化能源分析工具,不仅为开发者提供了在应用程序开发和调试过程中分析和优化能源消耗的能力,而且有助于学术界和工业界理解智能手机应用程序的能源效率问题。此外,通过公开共享研究成果,该论文还...
- 使用Erlang提供的各种工具和命令来辅助分析。例如,`observer`工具可以提供关于内存使用和进程状态的直观视图。 - 当使用第三方工具(如appmon,webtool)由于内存不足无法启动时,可以依赖Erlang shell本身提供...
虽然它可能不如专门的剖析工具(如Erlang的`eprof` 或Elixir的`memory_profiler`)强大,但在快速诊断时非常实用。 ### 文件结构 `observer_cli-master` 这个文件名表明这是`observer_cli` 的源码仓库主分支。如果...