`
langzhe
  • 浏览: 279302 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

eprof代码分析工具

阅读更多

清参考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前面。否则日志里面没有数据

  log(File) -> ok

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.
 

 

 

0
2
分享到:
评论

相关推荐

    Erlang--性能分析工具之eprof

    NULL 博文链接:https://room-bb.iteye.com/blog/2290355

    eurosys 2012

    where is the energy spent inside my app fine grained energy accounting on smartphones with eprof.发表于Eurosys 2012,被引用34次。

    波士顿房价数据集Boston House Price

    波士顿房价数据集Boston House Price 全网最便宜

    FPGA实现UDP协议(包括ARP、ICMP)

    三种实现FPGA实现UDP协议的代码工程(包括ARP、ICMP),包含使用设计文档。 第一种,米联客的DCP封装包 第二种,正点原子的源码工程 第三种,基于正点原子的赛灵思MAC核的代码工程。

    Red-Hat-Enterprise-Linux-7-RPM-Packaging-Guide-en-US

    Red_Hat_Enterprise_Linux-7-RPM_Packaging_Guide-en-US

    Matlab 三维人脸识别系统 V 4.3.zip

    Matlab 三维人脸识别系统 V 4.3.zip

    信捷XD PLC MODBUS控制阀岛通信 案例程序

    信捷XD PLC MODBUS控制阀岛通信 案例程序

    常用进制转换器16进制10进制2进制转换计算器..exe

    大家好呀!今天来介绍一款常用进制转换器,也就是 16 进制、10 进制、2 进制转换计算器。有了它,你可以轻松实现不同进制之间的快速转换。无论是将 16 进制转换为 10 进制或 2 进制,还是从其他进制转换过来,它都能准确而高效地完成。无论是在计算机编程、数字电路等领域,还是日常对进制转换有需求的时候,它都能成为你的得力小助手,让进制转换不再麻烦,快来试试吧!

    微信小程序:智能排队取号系统 - 地图组件集成

    这款微信小程序是一个创新的智能排队取号系统,专为提高服务行业的效率和顾客满意度而设计。它通过集成地图组件,为用户提供了一个直观、易用的排队和取号解决方案。用户可以在小程序中查看各个服务点的位置,实时了解排队情况,并进行远程取号。 小程序的主要功能包括: 实时排队信息:用户可以实时查看各个服务点的排队情况,包括当前排队人数、预计等待时间等。 远程取号:用户无需到现场即可通过小程序远程取号,节省了排队等待的时间。 地图导航:集成的地图组件可以帮助用户快速找到服务点的具体位置,并提供导航服务。 取号管理:用户可以在小程序中管理自己的取号信息,包括查看、取消等操作。 此外,小程序还支持多种场景,如餐饮、医疗、银行、政府服务等,适用于各种需要排队取号的服务场合。它不仅提高了服务效率,减少了顾客的等待时间,还为商家提供了客流管理和数据分析的工具。

    520节日520节日表白神器.zip

    520节日520节日表白神器520节日520节日表白神器520节日520节日表白神器520节日520节日表白神器

    JAVA语言考试系统的设计与实现(LW+源代码+文献综述+外文翻译+开题报告).zip

    JAVA语言考试系统的设计与实现(LW+源代码+文献综述+外文翻译+开题报告)

    相移法偏移MATLAB代码.zip

    相移法偏移MATLAB代码.zip

    directx修复工具directx修复工具directx修复工具.txt

    directx修复工具directx修复工具directx修复工具directx修复工具

    基于matlab的三维地球建模,需联网.zip

    基于matlab的三维地球建模,需联网.zip

    字符串处理-I.MX6U嵌入式Linux C应用编程学习笔记基于正点原子阿尔法开发板

    字符串处理-I.MX6U嵌入式Linux C应用编程学习笔记基于正点原子阿尔法开发板

    蓝桥杯-基础题C++: 其压缩包中为C++ code

    参加比赛的一些心得:感觉把比赛得那一门语言基础学会,输入输出([我写的python输入输出](https://blog.csdn.net/qq_41392228/article/details/123614298)),([C++的STL](https://blog.csdn.net/qq_41392228/article/details/124825895)),熟练里面的数据结构,如数组,map等,==主要还是基础==。熟悉了后,可以在刷一下基础题,巩固哈学了的基础知识。把基础学好了,拿个奖是没问题的,正常发挥即可。想那个好的名词,就要看看相关的算法了,主要就是暴力的+优化,BFS,DFS,比较难的就是动态规划,得找转换方程。 python版本的可见:https://blog.csdn.net/qq_41392228/article/details/123616441

    基于 Rust + eBPF 丢弃 GFW DNS 污染包

    基于 Rust + eBPF 丢弃 GFW DNS 污染包 GFW 污染 DNS 的方式为抢答,我们只需要丢弃投毒响应即可获得正确的解析结果。通过 eBPF 我们可以在内核中插入代码,相比在用户态启动代理,这样可以获得更好的性能。 要丢弃投毒响应,重点是找到它们的特征。 以 twitter.com 为例,当向 8.8.8.8 请求 twitter.com 的 A 记录时,正常的响应会返回 2 条结果(1Q2A);而 GFW 只会返回 1 条,但是使用了 2 次抢答。2 次抢答包其中一个 IP Identification = 0x0000,另一个 IP Flags = 0x40(Don't fragment);而正常的响应 IPID 不会是 0 并且 IP Flags = 0。 我们只要 Drop 掉符合对应特征的包即可。这时我们可以验证,twitter.com 可以正确解析(fb 等非 google 服务也正常)。

Global site tag (gtag.js) - Google Analytics