Profiler

From Resin 3.0

Revision as of 13:30, 28 November 2005 by Sam (Talk | contribs)
Jump to: navigation, search

Resin includes high level profiling capability for profiling requests and database conenctions.

Contents

Enabling the Profiler

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

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.profiler.ProfilerFilter">
     <init use-query="false"/>
   </filter>
 
   <filter-mapping filter-name="resin-profiler" url-pattern="*">
     <dispatcher>REQUEST</dispatcher>
   </filter-mapping>

View Results


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


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.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>

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

Profiling databases

The profiler-point directive is used in the database driver to configure profiling of database usage. Results are given for each unique sql statement or prepared statement.

Database profiling imposes more overhead than request profiling and should be used on production servers with care.

<database jndi-name="jdbc/caucho/crm">
   <driver>
     <type>org.postgresql.Driver</type>
     <url>jdbc:postgresql://127.0.0.1:5432/...</url>
     <user>...</user>
     <password>...</password>
 
     <profiler-point/>
   </driver>
 
   <spy/>
 </database>

View results

Profiling Results for /webapp
NameAverage TimeTotal TimeInvocation Count
/usedatabase.jsp
4.1984.1981
  →jdbc:postgresql://127.0.0.1:5432/test
8.007
    →INSERT INTO Address (ID, city, country, line1, line2, state, zip) VALUES (?, ?, ?, ?, ?, ?, ?)
0.0031.863560
    →INSERT INTO Contact (ID, email, fax, mobile, phone) VALUES (?, ?, ?, ?, ?)
0.0031.262420
    →SELECT c.ID, c.address, c.comment, c.contact, c.customerType, c.name, c.url FROM Customer c WHERE (c.name = ?)
0.0040.963213
    →INSERT INTO Customer (ID, address, comment, contact) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
0.0020.499187
    →SELECT Nextval('Address_cseq')
0.0880.1762
    →SELECT CustomerType.ID, CustomerType.name FROM CustomerType CustomerType WHERE (CustomerType.name = ?)
0.0050.16430

JMX

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

Personal tools