[slf4j-dev] svn commit: r1120 - slf4j/trunk/slf4j-api/src/test/java/org/slf4j/helpers

ceki at slf4j.org ceki at slf4j.org
Fri Aug 29 17:14:00 CEST 2008


Author: ceki
Date: Fri Aug 29 17:14:00 2008
New Revision: 1120

Modified:
   slf4j/trunk/slf4j-api/src/test/java/org/slf4j/helpers/MessageFormatterPerfTest.java

Log:
- use BogoPerf utility. 
- Using System.currentMillis instead of System.nanoTime. The latter is only available in
  JDK 1.5 

Modified: slf4j/trunk/slf4j-api/src/test/java/org/slf4j/helpers/MessageFormatterPerfTest.java
==============================================================================
--- slf4j/trunk/slf4j-api/src/test/java/org/slf4j/helpers/MessageFormatterPerfTest.java	(original)
+++ slf4j/trunk/slf4j-api/src/test/java/org/slf4j/helpers/MessageFormatterPerfTest.java	Fri Aug 29 17:14:00 2008
@@ -22,38 +22,37 @@
 
   public void XtestJDKFormatterPerf() {
     jdkMessageFormatter(RUN_LENGTH);
-    double avg = jdkMessageFormatter(RUN_LENGTH);
-    System.out.println("jdk avg = "+avg+" nanos");
+    double duration = jdkMessageFormatter(RUN_LENGTH);
+    System.out.println("jdk duration = "+duration+" nanos");
   }
   
   public void testSLF4JPerf() {
     slf4jMessageFormatter(RUN_LENGTH);
-    double avgDuration = slf4jMessageFormatter(RUN_LENGTH);
-    
-    long referencePerf = 1700;
-    BogoPerf.assertDuration(avgDuration, referencePerf, REFERENCE_BIPS);
+    double duration = slf4jMessageFormatter(RUN_LENGTH);
+    long referencePerf = 140;
+    BogoPerf.assertDuration(duration, referencePerf, REFERENCE_BIPS);
   }
 
   public double slf4jMessageFormatter(long len) {
     String s = ""; 
     s += ""; // keep compiler happy
-    long start = System.nanoTime();
+    long start = System.currentTimeMillis();
     for (int i = 0; i < len; i++) {
       s = MessageFormatter.format("This is some rather short message {} ", i1);
     }
-    long end = System.nanoTime();
-    return (1.0*end - start) / len;
+    long end = System.currentTimeMillis();
+    return (1.0*end - start);
   }  
   public double jdkMessageFormatter(long len) {
     String s = ""; 
     s += ""; // keep compiler happy
-    long start = System.nanoTime();
+    long start = System.currentTimeMillis();
     Object[] oa = new Object[] {i1};
     for (int i = 0; i < len; i++) {
       s = MessageFormat.format("This is some rather short message {0}", oa);
     }
-    long end = System.nanoTime();
-    return (1.0*end - start) / len;
+    long end = System.currentTimeMillis();
+    return (1.0*end - start);
   }
 
 }



More information about the slf4j-dev mailing list