コード例 #1
0
ファイル: Client.java プロジェクト: xinjiacs/ycsb-0.1.4
  /**
   * Exports the measurements to either sysout or a file using the exporter loaded from conf.
   *
   * @throws IOException Either failed to write to output stream or failed to close it.
   */
  private static void exportMeasurements(Properties props, int opcount, long runtime)
      throws IOException {
    MeasurementsExporter exporter = null;
    try {
      // if no destination file is provided the results will be written to stdout
      OutputStream out;
      String exportFile = props.getProperty("exportfile");
      if (exportFile == null) {
        out = System.out;
      } else {
        out = new FileOutputStream(exportFile);
      }

      // if no exporter is provided the default text one will be used
      String exporterStr =
          props.getProperty(
              "exporter", "com.yahoo.ycsb.measurements.exporter.TextMeasurementsExporter");
      try {
        exporter =
            (MeasurementsExporter)
                Class.forName(exporterStr).getConstructor(OutputStream.class).newInstance(out);
      } catch (Exception e) {
        System.err.println(
            "Could not find exporter " + exporterStr + ", will use default text reporter.");
        e.printStackTrace();
        exporter = new TextMeasurementsExporter(out);
      }

      exporter.write("OVERALL", "RunTime(ms)", runtime);
      double throughput = 1000.0 * ((double) opcount) / ((double) runtime);
      exporter.write("OVERALL", "Throughput(ops/sec)", throughput);

      Measurements.getMeasurements().exportMeasurements(exporter);
    } finally {
      if (exporter != null) {
        exporter.close();
      }
    }
  }
コード例 #2
0
ファイル: Client.java プロジェクト: RamuRChenchaiah/YCSB
 public void exportOverall() {
   try {
     Measurements.getMeasurements().exportMeasurementsFinal(exporter);
     long opcount = 0;
     long runtime = 0;
     long recon = 0;
     for (Thread t : _threads) {
       ClientThread ct = (ClientThread) t;
       opcount += ct.getOpsDone();
       if (runtime < ct.getRuntime()) {
         runtime = ct.getRuntime();
       }
       recon += ct.getReconnections();
     }
     exporter.write("OVERALL", "Reconnections", recon);
     exporter.write("OVERALL", "RunTime(ms)", runtime);
     exporter.write("OVERALL", "Operations", opcount);
     double throughput = 1000.0 * ((double) opcount) / ((double) runtime);
     exporter.write("OVERALL", "Throughput(ops/sec)", throughput);
     exporter.close();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }