[logback-dev] svn commit: r1731 - logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util

noreply.ceki at qos.ch noreply.ceki at qos.ch
Mon Aug 4 23:23:37 CEST 2008


Author: ceki
Date: Mon Aug  4 23:23:37 2008
New Revision: 1731

Modified:
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/BogoPerf.java

Log:
BogoPerf outputs data for debugging purposes

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/BogoPerf.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/BogoPerf.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/BogoPerf.java	Mon Aug  4 23:23:37 2008
@@ -15,17 +15,17 @@
   private static int SLACK = 2;
 
   static {
-    System.out.println("Host runs at "+INITIAL_BOGO_IPS + " BIPS");
+    System.out.println("Host runs at " + INITIAL_BOGO_IPS + " BIPS");
   }
-  
+
   /**
    * Compute bogoInstructions per second
    * <p>
    * on a 3.2 Ghz Pentium D CPU (around 2007), we obtain about 10'000 bogoIPS.
    * 
    * @param N
-   *                number of bogoInstructions to average over in order to
-   *                compute the result
+   *          number of bogoInstructions to average over in order to compute the
+   *          result
    * @return bogo Instructions Per Second
    */
   private static double computeBogoIPS(int N) {
@@ -70,8 +70,8 @@
   }
 
   /**
-   * Assertion used for values that <b>decrease</b> with faster CPUs, 
-   * typically the time (duration) needed to perform a task.
+   * Assertion used for values that <b>decrease</b> with faster CPUs, typically
+   * the time (duration) needed to perform a task.
    * 
    * @param currentDuration
    * @param referenceDuraion
@@ -79,17 +79,28 @@
    * @throws AssertionFailedError
    */
   public static void assertDuration(double currentDuration,
-      long referenceDuraion, double referenceBIPS)
-      throws AssertionFailedError {
+      long referenceDuraion, double referenceBIPS) throws AssertionFailedError {
     double ajustedDuration = adjustExpectedDuration(referenceDuraion,
         referenceBIPS);
+
     if (currentDuration > ajustedDuration * SLACK) {
       throw new AssertionFailedError(currentDuration + " exceeded expected "
           + ajustedDuration + " (adjusted), " + referenceDuraion + " (raw)");
     }
   }
+
+  private static double adjustExpectedDuration(long referenceDuration,
+      double referenceBIPS) {
+    double currentBIPS = currentBIPS();
+    double adjusted = referenceDuration * (referenceBIPS / currentBIPS);
+    System.out.println("currentBIPS=" + currentBIPS + ", referenceBIPS="
+        + referenceBIPS + ", adjustedDur=" + adjusted + ", referenceDur="
+        + referenceDuration);
+    return adjusted;
+  }
+
   /**
-   * Assertion used for values that <b>increase<b> with faster CPUs, typically 
+   * Assertion used for values that <b>increase<b> with faster CPUs, typically
    * the number of operations accomplished per unit of time.
    * 
    * @param currentPerformance
@@ -102,21 +113,16 @@
       throws AssertionFailedError {
     double ajustedPerf = adjustExpectedPerformance(referencePerformance,
         referenceBIPS);
-    if (currentPerformance*SLACK < ajustedPerf) {
+    if (currentPerformance * SLACK < ajustedPerf) {
       throw new AssertionFailedError(currentPerformance + " below expected "
           + ajustedPerf + " (adjusted), " + referencePerformance + " (raw)");
     }
   }
-  
+
   private static double adjustExpectedPerformance(long referenceDuration,
       double referenceBIPS) {
     double currentBIPS = currentBIPS();
-    return referenceDuration * (currentBIPS/referenceBIPS);
-  }
-  
-  private static double adjustExpectedDuration(long referenceDuration,
-      double referenceBIPS) {
-    double currentBIPS = currentBIPS();
-    return referenceDuration * (referenceBIPS / currentBIPS);
+    return referenceDuration * (currentBIPS / referenceBIPS);
   }
+
 }


More information about the logback-dev mailing list