<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)">Hello, every one,</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)">
            I am a rookie in erlang. Recently I am trying to use the dbg and fprof module to profile a running server to observe the performance. Since the server is based on mochiweb, a quite popular web server framework, and I only wish to see the performance of my own code, I tried the dbg module. I have tried in the following two ways:</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)">
1: use dbg to write trace to file and use fprof to analyse the result</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)"><div>dbg:stop_clear(),</div>
<div>dbg:tracer(port,dbg:trace_port(file,"fprof.trace")),</div><div>dbg:tpl(util,[]),</div><div>dbg:tpl(...),<span style="white-space:pre-wrap">        </span></div><div>dbg:p(all,[call,return_to, procs, timestamp,running,garbage_collection]),</div>
</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)"><div>dbg:stop_clear(),</div><div>fprof:profile(),</div><div><div>Fname = lists:append("profile/",Name),</div>
<div>fprof:analyse({dest, Fname}).</div></div></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)">
2: like fprof, but use dbg:tpl to confine the module</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)"><div>fprof:trace([start, {procs, all}]),</div>
<div>dbg:tpl(util,[]),</div><div>dbg:tpl(...),<span style="white-space:pre-wrap">     </span></div><div>fprof:trace([stop]),</div><div>fprof:profile(),</div><div>Fname = lists:append("profile/",Name),</div><div>fprof:analyse({dest, Fname}).</div>
</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)">
Sadly, neither way seems to work. </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)">
So any idea about how to combine the dbg and fprof module? </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)">Or maybe someone would like to point out the mistake I have made?</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.800000190734863px;background-color:rgb(255,255,255)">
Thanks in advance for your reply~</div><div><br></div>-- <br>   陈波 / Bill<br>   2009级本科生<br>   清华大学软件学院<br>------------------------------------------------------------<br>   Chen Bo<br>   School of Software<br>   Tsinghua University<br>
   Add: Building Zijing 1# Room 210B,<br>           Tsinghua University Beijing 100084<br>           P.R.CHINA<br>   Tel:  +86-010-51534210<br>   E-mail: <a href="mailto:chenbo09thss@gmail.com">chenbo09thss@gmail.com</a><br>