-
Notifications
You must be signed in to change notification settings - Fork 2
Use Perf4J for instrumentation and calculating performance statistics [CLOSED]
Have second thoughts. Perf4J isn't integrated nicely with JSON. Considering Yammer from Codehaus.
Up until this point, we have been using System.currentTimeMillis()
to calculate performance of our programs. Well this is going to change now.
Rule: To calculate performance metrics in your programs, use Perf4J framework.
The text below is taken directly from Perf4J site, without any modifications.
Perf4J is to System.currentTimeMillis() as log4j is to System.out.println()
Similarly, when new Java developers discover that they need to time specified blocks of code for performance logging and monitoring reasons, they often do something like this:
long start = System.currentTimeMillis();
// execute the block of code to be timed
System.out.println("ms for block n was: " + (System.currentTimeMillis() - start));
Later on, though, these developers find they want more information, such as aggregated performance statistics like mean, minimum, maximum, standard deviation and transactions per second over a set time span. They would like graphs of these values in real time to detect problems on a running server, or they would like to expose performance metrics through JMX. In addition, they want their timing statements to work with the common logging frameworks.
Perf4J provides these features and more:
A simple stop watch mechanism for succinct timing statements.
- A command line tool for parsing log files that generates aggregated statistics and performance graphs.
- Easy integration with the most common logging frameworks and facades: log4j, java.util.logging, Apache Commons Logging and SLF4J (including logback).
- Custom log4j and logback appenders to generate statistics and graphs in a running application.
- The ability to expose performance statistics as JMX attributes, and to send notifications when statistics exceed specified thresholds.
- A servlet for exposing performance graphs in a web application.
For more information, please visit: http://perf4j.codehaus.org/devguide.html