关于erlang:使用fprof-profile-erlang

5次阅读

共计 1127 个字符,预计需要花费 3 分钟才能阅读完成。

概述

不谈 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…

正文完
 0