01: package org.jzonic.jlo;
02:
03: import junit.framework.Test;
04: import junit.framework.TestCase;
05: import junit.framework.TestSuite;
06:
07: public class TimeTrackerTest extends TestCase {
08:
09: public TimeTrackerTest(String testName) {
10: super (testName);
11: }
12:
13: public static void main(String[] args) {
14: junit.textui.TestRunner.run(suite());
15: }
16:
17: public static Test suite() {
18: TestSuite suite = new TestSuite(TimeTrackerTest.class);
19: return suite;
20: }
21:
22: public void testTimeTracking() {
23: Logger logger = LogManager
24: .getLogger("org.jzonic.jlo", "simple");
25: long now = System.currentTimeMillis();
26: TimeTracker.start();
27: for (int i = 0; i < 10; i++) {
28: logger.fatal("Hallo");
29: }
30: long elapsed = (System.currentTimeMillis() - now);
31: System.out.println("Total time:" + elapsed + "ms");
32: double div = (double) elapsed / 10.0;
33: System.out.println("Time for one:" + div * 10.0
34: + "microseconds");
35: TimeTracker.stop();
36: }
37: }
|