JETM Performance monitoring strategies
The Java™ Execution Time Measurement Library targets two performance monitoring strategies:
- Programmatic performance monitoring activated at source code level.
- Declarative performance monitoring activated at application compile, load or runtime.
Even though these strategies serve different purposes they are still able to utilize the full JETM feature set and can be used at the same time or separately.
Programmatic performance monitoring
In Java™ land everyone should know the two most important keywords for programmatic performance monitoring: try and finally. Using try/finally blocks as foundation JETM provides a simple infrastructure to collect execution times for further analysis. All you need to do is to assign symbolic names to distinct code blocks as seen in the example below.
EtmMonitor monitor = ... EtmPoint point = monitor.createPoint("SymbolicName"); try { // arbitrary code fragment } finally { point.collect(); }
For further details regarding programmatic performance monitoring see:
Declarative performance monitoring
Although programmatic performance monitoring is a good place to start with it will clutter your source code pretty soon. Usually you will end up with inconsistent measurements across your application that exist purely based on developer needs.
With the advent of Aspect Oriented Programming and Aspect Oriented Frameworks such as AspectJ, Spring AOP or AspectWerkz there is no need to alter source code for performance monitoring. This is due to the fact that these frameworks have the capability to add or remove any arbitrary code fragment at compile, load or even runtime. JETM comes with several integrations to support declarative performance monitoring out of the box, nevertheless it should be possible to implementation custom integrations fairly easily.
For further details regarding declarative performance monitoring see: