Reputation: 1000
I'm develop RESTful web service and I want to put the request time processing into xml response for all request.
I'm use Netbeans 6.9.1 and GlassFish version 3.
How can I measure ?
Thank you.
Upvotes: 1
Views: 1025
Reputation: 1937
This is a bad idea for 2 reasons:
Now, it's good that you care about performance, but rather than return those metrics to the user, I would record those behind-the-scenes in your system logs, which you can review at any time. There's many ways to do that, but here are 2 common patterns.
long start = System.currentTimeMillis()
at the entry point to your code, another call to System.currentTimeMillis()
at the exit point to your code, compute the difference, and just log.info()
it out.Here's a working example I copied from a Spring Application Context file.
<bean id="springPerformanceMonitorAspectInterceptor" class="org.springframework.aop.interceptor.PerformanceMonitorInterceptor">
<property name="loggerName" value="com.myProject.performanceMonitor" />
</bean>
<aop:config>
<aop:pointcut id="springMonitoringPointcut" expression="execution(* com.myProject..*(..))" />
<aop:advisor pointcut-ref="springMonitoringPointcut" advice-ref="springPerformanceMonitorAspectInterceptor" />
</aop:config>
Upvotes: 1