1 package org.jzonic.jlo; 2 3 import junit.framework.Test; 4 import junit.framework.TestCase; 5 import junit.framework.TestSuite; 6 7 public class TimeTrackerTest extends TestCase { 8 9 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.getLogger("org.jzonic.jlo","simple"); 24 long now = System.currentTimeMillis(); 25 TimeTracker.start(); 26 for ( int i = 0; i < 10;i++) { 27 logger.fatal("Hallo"); 28 } 29 long elapsed = (System.currentTimeMillis()-now); 30 System.out.println("Total time:" + elapsed + "ms" ); 31 double div = (double)elapsed/10.0; 32 System.out.println("Time for one:"+ div*10.0 +"microseconds" ); 33 TimeTracker.stop(); 34 } 35 } 36 | Popular Tags |