I am carrying out a performance study for any web application framework running on Apache Tomcat 6.

I am attempting to appraise the time overhead of handling HTTP demands.

What I must do is:

/

// just before first request byte is read
long t1 = System.nanoTime();

// request is processed...

// just after final byte is written to response
long t2 = System.nanoTime();

/

I Quickly would compute the entire time (t2 - t1).

It is possible to method of doing this? Interesting help!

One alternative, that wouldn't require any coding whatsoever, is to check out the network traffic having a tool like Wireshark.

I believe you are able to accomplish this with the addition of a Filter and set your timing code pre and post your call to doFilter around the relaxation from the filter chain.

The easiest method to track this really is most likely having a Valve.

However I could be surprised if the is not already monitored within the MBeans that Tomcat exports. Particularly, the MBean Catalina:name=http-<my port num>,type=GlobalRequestProcessor lists the next characteristics:

bytesSent=51829989
bytesReceived=
processingTime=11464
errorCount=8
maxTime=1250
requestCount=923
modelerType=org.apache.coyote.RequestGroupInfo

Have a look in the documentation on Monitoring and Managing Tomcat to learn how to access these MBeans with JMX.

AspectJ you solution. Utilizing it that you can do anything__ with classes loaded by application CL(although not by bootstrap CL).