使用jprofile侦查你app的性能瓶颈

题记:

    最近的工作被focus到product的performance上,用jprofile统计了下消耗CPU的情况,或者说app运行时间的大致情况。

 

安装和集成WAS容器

刚开始jprofile把我现有的WAS环境给弄坏了,不得不重装。

 

WAS7.0版本

jprofile6.2.3(官网有体验版本)

windows XP

jprofile主要是在JVM启动的时候加入自己的agent,这个agent监控JVM的运行情况,并默认开启8849端口给jprofile client来显示数据。

 

与WAS7.0集成步骤:把WAS中wasprofile下的server.xml配置下(一时我还没找到在哪=.=),比如我的在:E:\Program Files\IBM\SDP\runtimes\base_v7\profiles\was70profile2\config\cells\yangjunDesktopNode02Cell\nodes\yangjunDesktopNode02\servers\server1\server.xml(修改前记得备份)

 

在server.xml中找到:

 

<jvmEntries xmi:id="JavaVirtualMachine_1183121908656" verboseModeClass="false" verboseModeGarbageCollection="false" verboseModeJNI="false" runHProf="false" debugMode="true" debugArgs="-Dcom.ibm.ws.classloader.j9enabled=true -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=7778" genericJvmArguments="-Xquickstart -agentpath:E:\\PROGRA~2\\jprofiler6\\bin\\windows\\jprofilerti.dll " disableJIT="false">

 

其中红色那段是我加上去的,然后重启WAS,打开jprofile进行connect就OK了。

 

除了以上方法,jprofile提供与eclipse的integer,不过这个我没弄成。

 

Monitor你的app

加入需要monitor的jar和class forder到jprofile,这样才能统计出你的项目中性能瓶颈在哪个方法上,并计算出每个方法所消耗的时间,Session设置如下:

 


 

CPU Views结果

 

启动Record CPU后,你看到如下结果: