Java Simon 是一个简单的监控 API ,可用于监控 Java 程序中的执行情况,监控代码直接植入应用程序中。
例如下面的代码:
// get us some stopwatch Simon Stopwatch stopwatch = SimonManager.getStopwatch(“org.javasimon.examples.HelloWorld-stopwatch”);
Split split = stopwatch.start(); // start the stopwatch System.out.println(“Hello world, ” + stopwatch); // print it split.stop(); // stop it
System.out.println(“Result: ” + stopwatch); // here we print our stopwatch again
输入结果:
Hello world, Simon Stopwatch: [org.javasimon.examples.HelloWorld-stopwatch INHERIT] total 0 ns, counter 0, max 0 ns, min undef Result: Simon Stopwatch: [org.javasimon.examples.HelloWorld-stopwatch INHERIT] total 59.2 ms, counter 1, max 59.2 ms, min 59.2 ms