Profileとは?

一般にシステムが動くときに使用されるコードには局所性がある(Paretoの法則? etc.)ので、システムを最適化するときにはよく使われるコードをチューニングした方が効率的です。

例:
平均して80%の処理時間を食うモジュールをチューニングして、
半分の時間で動くようになったとすると、システム全体は、
 100 - (20 + 80/2) = 40% 高速化される

ところが、平均して20%の処理時間しか食っていないモジュールをチューニングして、
半分の時間で動くようになるようにしても、システム全体は、
 100 - (20/2 + 80) = 10% しか高速化されない

Profilerは、実際に動いているシステムがどのような順序と頻度でプログラムのモジュールを呼んでいるかを調べるソフトウェアです。

Eclipse Profile plugin

http://eclipsecolorer.sourceforge.net/index_profiler.html

main()から始まる単体アプリのProfile

  1. main()メソッドを持つクラスを選択したまま、[実行]-[Profiler]を選択します
    profile.png
  2. 初回起動時には以下のダイアログがでて、ProfilerDLL.dll がコピーされます
    profile2.png

ServletのProfile(Tomcat on Eclipse Sysdeo plugin)

  1. Tomcat(Sysdeo plugin)の設定
     
    1. Sysdeoは、少しでも設定するとデフォルト設定が消えてしまいます。そこで、以下のJSPを動かして、あらかじめSysdeoのデフォルト設定を調べました。(手っ取り早く動く環境を作るためにStrutsBlank?.warのWelcome.jspに追記しました)
      <%@page contentType="text/html;charset=UTF-8" %>
      <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
      <%@ taglib uri="/tags/struts-html" prefix="html" %>
      <%@ taglib uri="/tags/struts-logic" prefix="logic" %>
      <%@ page import="java.util.*" %>
      
      <html:html locale="true">
      <head>
      <title><bean:message key="welcome.title"/></title>
      <html:base/>
      </head>
      <body bgcolor="white">
      
      <logic:notPresent name="org.apache.struts.action.MESSAGE" scope="application">
        <font color="red">
          ERROR:  Application resources not loaded -- check servlet container
          logs for error messages.
        </font>
      </logic:notPresent>
      
      <h3><bean:message key="welcome.heading"/></h3>
      <p><bean:message key="welcome.message"/></p>
      
      <hr/>
      
      <table border="1">
      <% Properties props = System.getProperties(); %>
      <% List propKeyList = new ArrayList( props.keySet() ); %>
      <% Collections.sort(propKeyList); %>
      <% for( Iterator it = propKeyList.iterator() ; it.hasNext(); ){ %>
      <% String param = (String)it.next(); %>
      <tr>
      <th><%= param %></th>
      <td><%= props.getProperty( param ) %></td>
      </tr>
      <% } %>
      </table>
      
      </body>
      </html:html>
      私の環境では、実行結果はこのように なりました。
       
    2. 調べた環境変数を参考にSysdeoの設定で以下のようにTomcatの環境変数を設定します
      profile3.png
       
      1. JVMのパラメータ
        -XrunProfilerDLL:1 -D__PROFILER_USE_PACKAGE_FILTER=1
        -D__PROFILER_TIMING_METHOD=1
        -D__PROFILER_PACKAGE_FILTER=__M__sun.;__M__com.sun.;__M__java.;__M__javax.;__M__org.apache.
      2. クラスパス(java.class.path)
        C:\Program Files\Java\jdk1.5.0\lib\tools.jar
      3. ブートクラスパス(sun.boot.class.path)
        C:\Program Files\Java\jre1.5.0\lib\rt.jar
        C:\Program Files\Java\jre1.5.0\lib\jsse.jar
        C:\Program Files\Java\jre1.5.0\lib\jce.jar
        C:\Program Files\Java\jre1.5.0\lib\charset.jar
        C:\eclipse\plugins\ru.nlmk.eclipse.plugins.profiler.ui\profiler_trace.jar
        C:\eclipse\plugins\ru.nlmk.eclipse.plugins.profiler.ui\jakarta-regexp.jar
        C:\eclipse\plugins\ru.nlmk.eclipse.plugins.profiler.ui\commons-lang.jar
  2. Profilerの設定
    [実行]-[実行]で、Remote Profilerを作成します。
    profile4.png
     
  3. 後は普通通りSysdeoからTomcatを起動して、Remote Profilerを起動すれば、Servletのプロファイルができます。

参考文献

  1. http://eclipsecolorer.sourceforge.net/index_profiler.html
  2. http://www.atmarkit.co.jp/fjava/rensai2/eclipse2_06/eclipse06_1.html
  3. http://www.atmarkit.co.jp/fjava/rensai2/eclipse2_06/eclipse06_2.html

Java


添付ファイル: fileprofile4.png 2516件 [詳細] fileprofile3.png 2416件 [詳細] fileprofile.png 2343件 [詳細] fileprofile2.png 2307件 [詳細] filetomcat_default_env.html 3327件 [詳細]

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS   sitemap
Last-modified: 2006-02-18 (土) 01:23:32 (6636d)
Short-URL:
ISBN10
ISBN13
9784061426061