使用fprof profile erlang

概述

不談profile tools的重要性. erlang profile必定要看看下面這篇.
http://erlang.org/doc/efficie...
這篇blog記錄一些實操.css

步驟

fprof採集數據

在程序中, 或者直接remote_console觸發採集.html

:fprof.trace(:start)
# 一段時間後, 注意不要在線上採集, fprof時對性能影響最大的profile方式, 也有最全的信息
:fprof.trace(:stop)

不傳遞參數狀況下, 默認會將fprof信息寫入fprof.trace文件.git

使用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

能夠直接用包管理器安裝github

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

效果如圖:
image.pngide

flame graph

todo性能

參考

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

相關文章
相關標籤/搜索