commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From er...@apache.org
Subject svn commit: r1170697 - /commons/proper/math/trunk/src/test/java/org/apache/commons/math/PerfTestUtils.java
Date Wed, 14 Sep 2011 15:56:08 GMT
Author: erans
Date: Wed Sep 14 15:56:08 2011
New Revision: 1170697

URL: http://svn.apache.org/viewvc?rev=1170697&view=rev
Log:
Enhanced formatting of the results printed to stdout.

Modified:
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/PerfTestUtils.java

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/PerfTestUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/PerfTestUtils.java?rev=1170697&r1=1170696&r2=1170697&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/PerfTestUtils.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/PerfTestUtils.java Wed
Sep 14 15:56:08 2011
@@ -163,24 +163,49 @@ public class PerfTestUtils {
                                                      boolean runGC,
                                                      RunTest ... methods) {
         // Header format.
-        final String hFormat = "%s (calls per timed block: %d, timed blocks: %d)";
+        final String hFormat = "%s (calls per timed block: %d, timed blocks: %d, time unit:
ms)";
+
+        // Width of the longest name.
+        int nameLength = 0;
+        for (RunTest m : methods) {
+            int len = m.getName().length();
+            if (len > nameLength) {
+                nameLength = len;
+            }
+        }
+        final String nameLengthFormat = "%" + nameLength + "s";
+
+        // Column format.
+        final String cFormat = nameLengthFormat + " %14s %14s %10s %10s %15s";
         // Result format.
-        final String format = "%15s: %e (%e) ms";
+        final String format = nameLengthFormat + " %.8e %.8e %.4e %.4e % .8e";
 
         System.out.println(String.format(hFormat,
                                          title,
                                          repeatChunk,
                                          repeatStat));
+        System.out.println(String.format(cFormat,
+                                         "name",
+                                         "time/call",
+                                         "std error",
+                                         "total time",
+                                         "ratio",
+                                         "difference"));
         final StatisticalSummary[] time = time(repeatChunk,
                                                repeatStat,
                                                runGC,
                                                methods);
+        final double refSum = time[0].getSum();
         for (int i = 0, max = time.length; i < max; i++) {
             final StatisticalSummary s = time[i];
+            final double sum = s.getSum();
             System.out.println(String.format(format,
                                              methods[i].getName(),
                                              s.getMean(),
-                                             s.getStandardDeviation()));
+                                             s.getStandardDeviation(),
+                                             sum,
+                                             sum / refSum,
+                                             sum - refSum));
         }
 
         return time;



Mime
View raw message