Profiler

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
 
(Added description for filter init param "use-query")
 
(16 intermediate revisions by 6 users not shown)
Line 1: Line 1:
Resin includes high level profiling capability for profiling requests and database conenctions.
+
Resin includes high level profiling capability for profiling requests. <!-- and database conenctions. -->
  
 
= Enabling the Profiler =
 
= Enabling the Profiler =
Line 5: Line 5:
 
   <[[web-app]] ...>
 
   <[[web-app]] ...>
 
    
 
    
     <servlet-mapping servlet-class="com.caucho.profiler.ProfilerServlet" url-pattern="/resin-profiler">
+
     <servlet-mapping servlet-class="com.caucho.tools.profiler.ProfilerServlet" url-pattern="/resin-profiler">
 
       <init>
 
       <init>
         <profiler enabled="true" use-query="false"/>
+
         <profiler enabled="true"/>
 
       </init>
 
       </init>
 
       <load-on-startup/>
 
       <load-on-startup/>
 
     </servlet-mapping>
 
     </servlet-mapping>
 
== View Results ==
 
 
http://localhost:8080/webapp/resin-profiler
 
  
 
= Profiling requests =
 
= Profiling requests =
Line 25: Line 21:
 
    
 
    
 
     <filter filter-name="resin-profiler"
 
     <filter filter-name="resin-profiler"
             filter-class="com.caucho.profiler.ProfilerFilter">
+
             filter-class="com.caucho.tools.profiler.ProfilerFilter">
 
       <init use-query="false"/>
 
       <init use-query="false"/>
 
     </filter>
 
     </filter>
Line 33: Line 29:
 
     </filter-mapping>
 
     </filter-mapping>
  
 +
 +
Initialization Parameter  "use-query":
 +
 +
If true, use the query portion of the url to distinguish requests, default is false
 +
 +
 +
== View results ==
 +
 +
* Make a request, for example http://localhost:8080/webapp/foo.jsp
 +
* View results http://localhost:8080/webapp/resin-profiler
 +
 +
 +
    <table border='0'>
 +
      <caption>Profiling Results for /webapp</caption>
 +
      <tr><th>Name</th><th>Average Time</th><th>Total Time</th><th>Invocation Count</th></tr>
 +
      <tr class='level0'><td>
 +
          <table>
 +
            <tr><td></td><td class='text'>/foo.jsp</td></tr>
 +
          </table>
 +
 +
        </td><td class='number' title='totalTime=1.749 thisTime=0.369 childrenTime=1.379'>1.749</td><td class='number' title='totalTime=1.749 thisTime=0.369 childrenTime=1.379'>1.749</td><td class='number'>1</td></tr>
 +
      <tr class='level0'><td>
 +
          <table>
 +
            <tr><td></td><td class='text'>/resin-profiler</td></tr>
 +
 +
          </table>
 +
        </td><td class='number'>&nbsp;</td><td class='number' title='totalTime=0.000 thisTime=0.000 childrenTime=0.000'>0.000</td><td class='number'>0</td></tr>
 +
    </table>
 +
 +
== XML format ==
 +
 +
The output of the profiler can be returned in XML format using the query string "?format=xml".
 +
 +
== Sort order ==
 +
 +
By default, the entries are sorted descending by Total Time. To change the sort order to Invocation Count, just add the query string "?sort=count".
  
 
= Profiling sub-requests =
 
= Profiling sub-requests =
Line 44: Line 76:
 
    
 
    
 
     <filter filter-name="resin-profiler"
 
     <filter filter-name="resin-profiler"
             filter-class="com.caucho.profiler.ProfilerFilter">
+
             filter-class="com.caucho.tools.profiler.ProfilerFilter">
 
       <init use-query="false"/>
 
       <init use-query="false"/>
 
     </filter>
 
     </filter>
Line 55: Line 87:
 
     </filter-mapping>
 
     </filter-mapping>
  
 +
== View results ==
 +
 +
* Make a request, for example http://localhost:8080/webapp/foo.jsp
 +
* View results http://localhost:8080/webapp/resin-profiler
 +
 +
 +
    <table border='0'>
 +
      <caption>Profiling Results for /webapp</caption>
 +
      <tr><th>Name</th><th>Average Time</th><th>Total Time</th><th>Invocation Count</th></tr>
 +
      <tr class='level0'><td>
 +
          <table>
 +
            <tr><td></td><td class='text'>/foo.jsp</td></tr>
 +
          </table>
 +
 +
        </td><td class='number' title='totalTime=1.749 thisTime=0.369 childrenTime=1.379'>1.749</td><td class='number' title='totalTime=1.749 thisTime=0.369 childrenTime=1.379'>1.749</td><td class='number'>1</td></tr>
 +
      <tr class='level1'><td>
 +
          <table>
 +
            <tr><td>&nbsp;&nbsp;&rarr;</td><td class='text'>/baz.jsp</td></tr>
 +
          </table>
 +
        </td><td class='number' title='totalTime=0.863 thisTime=0.863 childrenTime=0.000'>0.863</td><td class='number' title='totalTime=0.863 thisTime=0.863 childrenTime=0.000'>0.863</td><td class='number'>1</td></tr>
 +
 +
      <tr class='level1'><td>
 +
          <table>
 +
            <tr><td>&nbsp;&nbsp;&rarr;</td><td class='text'>/bar.jsp</td></tr>
 +
          </table>
 +
        </td><td class='number' title='totalTime=0.575 thisTime=0.515 childrenTime=0.060'>0.575</td><td class='number' title='totalTime=0.575 thisTime=0.515 childrenTime=0.060'>0.575</td><td class='number'>1</td></tr>
 +
      <tr class='level2'><td>
 +
          <table>
 +
 +
            <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&rarr;</td><td class='text'>/bung.jsp</td></tr>
 +
          </table>
 +
        </td><td class='number' title='totalTime=0.060 thisTime=0.060 childrenTime=0.000'>0.060</td><td class='number' title='totalTime=0.060 thisTime=0.060 childrenTime=0.000'>0.060</td><td class='number'>1</td></tr>
 +
      <tr class='level0'><td>
 +
          <table>
 +
            <tr><td></td><td class='text'>/resin-profiler</td></tr>
 +
 +
          </table>
 +
        </td><td class='number'>&nbsp;</td><td class='number' title='totalTime=0.000 thisTime=0.000 childrenTime=0.000'>0.000</td><td class='number'>0</td></tr>
 +
    </table>
 +
<!--
 
= Profiling databases =
 
= Profiling databases =
  
Line 77: Line 149:
 
   </database>
 
   </database>
  
 +
== View results ==
 +
 +
* Make a request that uses the database. for example http://localhost:8080/webapp/foo.php
 +
* View results http://localhost:8080/webapp/resin-profiler
 +
    <table>
 +
      <caption>Profiling Results for /webapp</caption>
 +
      <tr><th>Name</th><th>Average Time</th><th>Total Time</th><th>Invocation Count</th></tr>
 +
      <tr class='level0'><td>
 +
          <table>
 +
            <tr><td></td><td class='text'>/usedatabase.jsp</td></tr>
 +
          </table>
 +
 +
        </td><td class='number' title='totalTime=4.198 thisTime=1.458 childrenTime=2.739'>4.198</td><td class='number' title='totalTime=4.198 thisTime=1.458 childrenTime=2.739'>4.198</td><td class='number'>1</td></tr>
 +
      <tr class='level1'><td>
 +
          <table>
 +
            <tr><td>&nbsp;&nbsp;&rarr;</td><td class='text'>jdbc:postgresql://127.0.0.1:5432/test</td></tr>
 +
          </table>
 +
        </td><td class='number'></td><td class='number' title='totalTime=8.007 thisTime=2.739 childrenTime=5.268'>8.007</td><td class='number'></td></tr>
 +
 +
      <tr class='level2'><td>
 +
          <table>
 +
            <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&rarr;</td><td class='text'>INSERT INTO Address (ID, city, country, line1, line2, state, zip) VALUES (?, ?, ?, ?, ?, ?, ?)</td></tr>
 +
          </table>
 +
        </td><td class='number' title='totalTime=0.003 thisTime=0.003 childrenTime=0.000'>0.003</td><td class='number' title='totalTime=1.863 thisTime=1.863 childrenTime=0.000'>1.863</td><td class='number'>560</td></tr>
 +
      <tr class='level2'><td>
 +
          <table>
 +
 +
            <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&rarr;</td><td class='text'>INSERT INTO Contact (ID, email, fax, mobile, phone) VALUES (?, ?, ?, ?, ?)</td></tr>
 +
          </table>
 +
        </td><td class='number' title='totalTime=0.003 thisTime=0.003 childrenTime=0.000'>0.003</td><td class='number' title='totalTime=1.262 thisTime=1.262 childrenTime=0.000'>1.262</td><td class='number'>420</td></tr>
 +
      <tr class='level2'><td>
 +
          <table>
 +
            <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&rarr;</td><td class='text'>SELECT c.ID, c.address, c.comment, c.contact, c.customerType, c.name, c.url FROM Customer c WHERE (c.name = ?)</td></tr>
 +
 +
          </table>
 +
        </td><td class='number' title='totalTime=0.004 thisTime=0.004 childrenTime=0.000'>0.004</td><td class='number' title='totalTime=0.963 thisTime=0.963 childrenTime=0.000'>0.963</td><td class='number'>213</td></tr>
 +
      <tr class='level2'><td>
 +
          <table>
 +
            <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&rarr;</td><td class='text'>INSERT INTO Customer (ID, address, comment, contact) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)</td></tr>
 +
          </table>
 +
        </td><td class='number' title='totalTime=0.002 thisTime=0.002 childrenTime=0.000'>0.002</td><td class='number' title='totalTime=0.499 thisTime=0.499 childrenTime=0.000'>0.499</td><td class='number'>187</td></tr>
 +
 +
      <tr class='level2'><td>
 +
          <table>
 +
            <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&rarr;</td><td class='text'>SELECT Nextval(&apos;Address_cseq&apos;)</td></tr>
 +
          </table>
 +
        </td><td class='number' title='totalTime=0.088 thisTime=0.088 childrenTime=0.000'>0.088</td><td class='number' title='totalTime=0.176 thisTime=0.176 childrenTime=0.000'>0.176</td><td class='number'>2</td></tr>
 +
      <tr class='level2'><td>
 +
 +
          <table>
 +
            <tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&rarr;</td><td class='text'>SELECT CustomerType.ID, CustomerType.name FROM CustomerType CustomerType WHERE (CustomerType.name = ?)</td></tr>
 +
          </table>
 +
        </td><td class='number' title='totalTime=0.005 thisTime=0.005 childrenTime=0.000'>0.005</td><td class='number' title='totalTime=0.164 thisTime=0.164 childrenTime=0.000'>0.164</td><td class='number'>30</td></tr>
  
 +
    </table>
 +
-->
 
= JMX =
 
= JMX =
  
The Profiler instantiates a [JMX] bean with type `Profiler'.
+
The Profiler instantiates a [[JMX]] bean with type `Profiler'.

Latest revision as of 20:11, 14 April 2008

Resin includes high level profiling capability for profiling requests.

Contents

[edit] Enabling the Profiler

 <web-app ...>
 
   <servlet-mapping servlet-class="com.caucho.tools.profiler.ProfilerServlet" url-pattern="/resin-profiler">
     <init>
       <profiler enabled="true"/>
     </init>
     <load-on-startup/>
   </servlet-mapping>

[edit] Profiling requests

Request profiling gives insight into the time taken for requests from client browsers.

It imposes very little overhead and is suitable for production servers.

 <web-app ...>
 
   <filter filter-name="resin-profiler"
           filter-class="com.caucho.tools.profiler.ProfilerFilter">
     <init use-query="false"/>
   </filter>
 
   <filter-mapping filter-name="resin-profiler" url-pattern="*">
     <dispatcher>REQUEST</dispatcher>
   </filter-mapping>


Initialization Parameter "use-query":

If true, use the query portion of the url to distinguish requests, default is false


[edit] View results


Profiling Results for /webapp
NameAverage TimeTotal TimeInvocation Count
/foo.jsp
1.7491.7491
/resin-profiler
 0.0000

[edit] XML format

The output of the profiler can be returned in XML format using the query string "?format=xml".

[edit] Sort order

By default, the entries are sorted descending by Total Time. To change the sort order to Invocation Count, just add the query string "?sort=count".

[edit] Profiling sub-requests

Sub-request profiling adds profiling information for pages that are sub-requests of the top level request, typically with <jsp:include>, <jsp:forward>, or the equivalent mechanisms for Servlets.

It imposes a bit more overhead and may be suitable for production servers.

 <web-app ...>
 
   <filter filter-name="resin-profiler"
           filter-class="com.caucho.tools.profiler.ProfilerFilter">
     <init use-query="false"/>
   </filter>
 
   <filter-mapping filter-name="resin-profiler" url-pattern="*">
     <dispatcher>REQUEST</dispatcher>
     <dispatcher>FORWARD</dispatcher>
     <dispatcher>INCLUDE</dispatcher>
     <dispatcher>ERROR</dispatcher>
   </filter-mapping>

[edit] View results


Profiling Results for /webapp
NameAverage TimeTotal TimeInvocation Count
/foo.jsp
1.7491.7491
  →/baz.jsp
0.8630.8631
  →/bar.jsp
0.5750.5751
    →/bung.jsp
0.0600.0601
/resin-profiler
 0.0000

[edit] JMX

The Profiler instantiates a JMX bean with type `Profiler'.

Personal tools