Showing posts with label monitor. Show all posts
Showing posts with label monitor. Show all posts

Tuesday, November 24, 2015

JAMon - nice and simple java monitor for measuring code performance in Java

General information

Official site: http://jamonapi.sourceforge.net/
A SourceForge project

Maven dependency

Place in pom.xml:
    <dependencies>
        <dependency>
            <groupId>com.jamonapi</groupId>
            <artifactId>jamon</artifactId>
            <version>2.81</version>
        </dependency>
    </dependencies>

Example 1

Code:

import com.jamonapi.*;


public class MonitorTest {
    public static void main(String[] args) throws Exception {
        Monitor mon=null;
        for (int i=1; i<=10; i++) {
            mon = MonitorFactory.start("myFirstMonitor");
            Thread.sleep(100+i);
            mon.stop();
        }
        System.out.println(mon);  // toString() method called
    }
}
Output:

Example 2