mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robina...@apache.org
Subject svn commit: r1470206 - /mahout/trunk/integration/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java
Date Sat, 20 Apr 2013 17:56:49 GMT
Author: robinanil
Date: Sat Apr 20 17:56:49 2013
New Revision: 1470206

URL: http://svn.apache.org/r1470206
Log:
MAHOUT print benchmarks as csv to make it easy to import into spreadsheets for comparison

Modified:
    mahout/trunk/integration/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java

Modified: mahout/trunk/integration/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java
URL: http://svn.apache.org/viewvc/mahout/trunk/integration/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java?rev=1470206&r1=1470205&r2=1470206&view=diff
==============================================================================
--- mahout/trunk/integration/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java
(original)
+++ mahout/trunk/integration/src/main/java/org/apache/mahout/benchmark/VectorBenchmarks.java
Sat Apr 20 17:56:49 2013
@@ -152,7 +152,7 @@ public class VectorBenchmarks {
 
   private void printStats(TimingStatistics stats, String benchmarkName, String implName,
       String content, int multiplier) {
-    float speed = multiplier * stats.getNCalls() * numNonZeros * 1000.0f * 12 / stats.getSumTime();
+    float speed = multiplier * stats.getNCalls() * (numNonZeros * 1000.0f * 12 / stats.getSumTime());
     float opsPerSec = stats.getNCalls() * 1000000000.0f / stats.getSumTime();
     log.info("{} {} \n{} {} \nOps    = {} Units/sec\nIOps   = {} MBytes/sec", benchmarkName,
         implName, content, stats.toString(), DF.format(opsPerSec), DF.format(speed));
@@ -369,6 +369,7 @@ public class VectorBenchmarks {
       runBenchmark(mark);
 
       log.info("\n{}", mark);
+      log.info("\n{}", mark.asCsvString());
     } catch (OptionException e) {
       CommandLineUtil.printHelp(group);
     }
@@ -410,6 +411,28 @@ public class VectorBenchmarks {
     centroidBenchmark.benchmark(new MinkowskiDistanceMeasure());
   }
 
+  private String asCsvString() {
+    StringBuilder sb = new StringBuilder(1000);
+    List<String> keys = Lists.newArrayList(statsMap.keySet());
+    Collections.sort(keys);
+    Map<Integer,String> implMap = Maps.newHashMap();
+    for (Entry<String,Integer> e : implType.entrySet()) {
+      implMap.put(e.getValue(), e.getKey());
+    }
+
+    for (String benchmarkName : keys) {
+      int i = 0;
+      for (String[] stats : statsMap.get(benchmarkName)) {
+        sb.append(benchmarkName + ",");
+        sb.append(implMap.get(i++) + ",");
+        sb.append(stats[7].trim().split("=|/")[1].trim());
+        sb.append('\n');
+      }
+    }
+    sb.append('\n');
+    return sb.toString();
+  }
+
   @Override
   public String toString() {
     int pad = 24;



Mime
View raw message