// Copyright 2011 Google Inc. All Rights Reserved.

package org.cachebench;

import org.cachebench.reportgenerators.CsvStatisticReportGenerator;

import java.io.File;

/**
 * An extension of the report generator to simplify the file name.
 *
 * @author bmanes@google.com (Ben Manes)
 */
public final class CustomCsvStatisticReportGenerator extends CsvStatisticReportGenerator {

  @Override public void setOutputFile(String fileName) {
    if ("-generic-".equals(fileName)) {
      String type = System.getProperty("cacheBenchFwk.cache.type");
      String run = System.getProperty("cacheBenchFwk.cache.run");
      this.output = new File(type + (run == null ? "" : "-" + run) + ".csv");
    } else {
      super.setOutputFile(fileName);
    }
  }
}

@@ -70,16 +70,75 @@
 bench;%0A%0A
+import static com.google.common.base.Strings.emptyToNull;%0A%0A
 import o
@@ -615,16 +615,28 @@
 g run = 
+emptyToNull(
 System.g
@@ -672,16 +672,17 @@
 he.run%22)
+)
 ;%0A      

Fix to remove '-' when no run specified