使用fprof profile erlang

概述

不谈profile tools的重要性. erlang profile一定要看看下面这篇.
http://erlang.org/doc/efficie...
这篇blog记录一些实操.

步骤

fprof采集数据

在程序中, 或者直接remote_console触发采集.

:fprof.trace(:start)
# 一段时间后, 注意不要在线上采集, fprof时对性能影响最大的profile方式, 也有最全的信息
:fprof.trace(:stop)

不传递参数情况下, 默认会将fprof信息写入fprof.trace文件.

使用kcachegrind 查看fprof的结果

使用erlgrind转化为callgrind格式

~/install » wget https://raw.githubusercontent.com/isacssouza/erlgrind/master/src/erlgrind
~/install » chmod a+x erlgrind 
~/install » sudo mv erlgrind /usr/local/bin
~/platform/xxxxx(xxxx*) » erlgrind fprof.trace
Reading trace data...
..................................................
.................................................,
..................................................
.................................................,
..................................................
.................................................,
..................................................
..............................
End of trace!
Processing data...
Creating output...
Done!

安装kcachegrind

可以直接用包管理器安装

sudo apt-get install -y kcachegrind
~/platform/xxxxx(xxxxx*) » kcachegrind xxx.cgrind

效果如图:

flame graph

todo

参考

http://erlang.org/doc/efficie...
http://blog.equanimity.nl/blo...

    作者:enjolras1205原文地址:https://segmentfault.com/a/1190000023456549

    %s 个评论

    要回复文章请先登录注册