mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Ludovic Poitou
04.13.2010 544536022b406231ae3b8fd55b69ebdd6a98e1e8
Add -S (--scriptFriendly) option to output all performance test results in CSV format so that they can be easily imported in tools such as spreadsheets. The CSV format includes an additional column (the first column) which is the time in seconds since the start of the test run.

4 files modified
182 ■■■■■ changed files
opendj-sdk/sdk/src/com/sun/opends/sdk/tools/AuthRate.java 12 ●●●●● patch | view | raw | blame | history
opendj-sdk/sdk/src/com/sun/opends/sdk/tools/ModRate.java 9 ●●●● patch | view | raw | blame | history
opendj-sdk/sdk/src/com/sun/opends/sdk/tools/PerformanceRunner.java 152 ●●●●● patch | view | raw | blame | history
opendj-sdk/sdk/src/com/sun/opends/sdk/tools/SearchRate.java 9 ●●●● patch | view | raw | blame | history
opendj-sdk/sdk/src/com/sun/opends/sdk/tools/AuthRate.java
@@ -42,10 +42,7 @@
import java.util.concurrent.atomic.AtomicLong;
import static com.sun.opends.sdk.messages.Messages.*;
import static com.sun.opends.sdk.messages.Messages.ERR_ERROR_PARSING_ARGS;
import static com.sun.opends.sdk.tools.ToolConstants.*;
import static com.sun.opends.sdk.tools.ToolConstants.OPTION_LONG_BASEDN;
import static com.sun.opends.sdk.tools.ToolConstants.OPTION_SHORT_BASEDN;
import static com.sun.opends.sdk.tools.Utils.filterExitCode;
/**
@@ -459,6 +456,8 @@
  private BooleanArgument verbose;
  private BooleanArgument scriptFriendly;
@@ -537,7 +536,7 @@
  @Override
  public boolean isScriptFriendly()
  {
    return false;
    return scriptFriendly.isPresent();
  }
@@ -641,6 +640,11 @@
          INFO_DESCRIPTION_VERBOSE.get());
      verbose.setPropertyName("verbose");
      argParser.addArgument(verbose);
      scriptFriendly = new BooleanArgument("scriptFriendly", 'S',
          "scriptFriendly", INFO_DESCRIPTION_SCRIPT_FRIENDLY.get());
      scriptFriendly.setPropertyName("scriptFriendly");
      argParser.addArgument(scriptFriendly);
    }
    catch (final ArgumentException ae)
    {
opendj-sdk/sdk/src/com/sun/opends/sdk/tools/ModRate.java
@@ -211,6 +211,8 @@
  private BooleanArgument verbose;
  private BooleanArgument scriptFriendly;
  private ModRate(final InputStream in, final OutputStream out,
@@ -288,7 +290,7 @@
  @Override
  public boolean isScriptFriendly()
  {
    return false;
    return scriptFriendly.isPresent();
  }
@@ -361,6 +363,11 @@
          OPTION_LONG_HELP, INFO_DESCRIPTION_SHOWUSAGE.get());
      argParser.addArgument(showUsage);
      argParser.setUsageArgument(showUsage, getOutputStream());
      scriptFriendly = new BooleanArgument("scriptFriendly", 'S',
          "scriptFriendly", INFO_DESCRIPTION_SCRIPT_FRIENDLY.get());
      scriptFriendly.setPropertyName("scriptFriendly");
      argParser.addArgument(scriptFriendly);
    }
    catch (final ArgumentException ae)
    {
opendj-sdk/sdk/src/com/sun/opends/sdk/tools/PerformanceRunner.java
@@ -56,7 +56,7 @@
   */
  class StatsThread extends Thread
  {
    private final MultiColumnPrinter printer;
    private final String[] additionalColumns;
    private final List<GarbageCollectorMXBean> beans;
@@ -97,6 +97,9 @@
    public StatsThread(final String[] additionalColumns)
    {
      super("Stats Thread");
      this.additionalColumns = additionalColumns;
      final TreeSet<Double> pSet = new TreeSet<Double>();
      if (!percentilesArgument.isPresent())
      {
@@ -112,51 +115,9 @@
        }
      }
      this.percentiles = pSet.descendingSet();
      numColumns = 5 + this.percentiles.size() + additionalColumns.length
      this.numColumns = 5 + this.percentiles.size() + additionalColumns.length
          + (isAsync ? 1 : 0);
      printer = new MultiColumnPrinter(numColumns, 2, "-",
          MultiColumnPrinter.RIGHT, app);
      printer.setTitleAlign(MultiColumnPrinter.RIGHT);
      String[] title = new String[numColumns];
      Arrays.fill(title, "");
      title[0] = "Throughput";
      title[2] = "Response Time";
      int[] span = new int[numColumns];
      span[0] = 2;
      span[1] = 0;
      span[2] = 2 + this.percentiles.size();
      Arrays.fill(span, 3, 4 + this.percentiles.size(), 0);
      Arrays.fill(span, 4 + this.percentiles.size(), span.length, 1);
      printer.addTitle(title, span);
      title = new String[numColumns];
      Arrays.fill(title, "");
      title[0] = "(ops/second)";
      title[2] = "(milliseconds)";
      printer.addTitle(title, span);
      title = new String[numColumns];
      title[0] = "recent";
      title[1] = "average";
      title[2] = "recent";
      title[3] = "average";
      int i = 4;
      for (final Double percentile : this.percentiles)
      {
        title[i++] = Double.toString(100.0 - percentile) + "%";
      }
      title[i++] = "err/sec";
      if (isAsync)
      {
        title[i++] = "req/res";
      }
      for (final String column : additionalColumns)
      {
        title[i++] = column;
      }
      span = new int[numColumns];
      Arrays.fill(span, 1);
      printer.addTitle(title, span);
      beans = ManagementFactory.getGarbageCollectorMXBeans();
      this.beans = ManagementFactory.getGarbageCollectorMXBeans();
    }
@@ -164,7 +125,86 @@
    @Override
    public void run()
    {
      printer.printTitle();
      final MultiColumnPrinter printer;
      if (!app.isScriptFriendly())
      {
        printer = new MultiColumnPrinter(numColumns, 2, "-",
            MultiColumnPrinter.RIGHT, app);
        printer.setTitleAlign(MultiColumnPrinter.RIGHT);
        String[] title = new String[numColumns];
        Arrays.fill(title, "");
        title[0] = "Throughput";
        title[2] = "Response Time";
        int[] span = new int[numColumns];
        span[0] = 2;
        span[1] = 0;
        span[2] = 2 + this.percentiles.size();
        Arrays.fill(span, 3, 4 + this.percentiles.size(), 0);
        Arrays.fill(span, 4 + this.percentiles.size(), span.length, 1);
        printer.addTitle(title, span);
        title = new String[numColumns];
        Arrays.fill(title, "");
        title[0] = "(ops/second)";
        title[2] = "(milliseconds)";
        printer.addTitle(title, span);
        title = new String[numColumns];
        title[0] = "recent";
        title[1] = "average";
        title[2] = "recent";
        title[3] = "average";
        int i = 4;
        for (final Double percentile : this.percentiles)
        {
          title[i++] = Double.toString(100.0 - percentile) + "%";
        }
        title[i++] = "err/sec";
        if (isAsync)
        {
          title[i++] = "req/res";
        }
        for (final String column : additionalColumns)
        {
          title[i++] = column;
        }
        span = new int[numColumns];
        Arrays.fill(span, 1);
        printer.addTitle(title, span);
        printer.printTitle();
      }
      else
      {
        app.getOutputStream().print("Time (seconds)");
        app.getOutputStream().print(",");
        app.getOutputStream().print("Recent throughput (ops/second)");
        app.getOutputStream().print(",");
        app.getOutputStream().print("Average throughput (ops/second)");
        app.getOutputStream().print(",");
        app.getOutputStream().print("Recent response time (milliseconds)");
        app.getOutputStream().print(",");
        app.getOutputStream().print("Average response time (milliseconds)");
        for (final Double percentile : this.percentiles)
        {
          app.getOutputStream().print(",");
          app.getOutputStream().print(Double.toString(100.0 - percentile));
          app.getOutputStream().print("% response time (milliseconds)");
        }
        app.getOutputStream().print(",");
        app.getOutputStream().print("Errors/second");
        if (isAsync)
        {
          app.getOutputStream().print(",");
          app.getOutputStream().print("Requests/response");
        }
        for (final String column : additionalColumns)
        {
          app.getOutputStream().print(",");
          app.getOutputStream().print(column);
        }
        app.getOutputStream().println();
        printer = null;
      }
      final String[] strings = new String[numColumns];
@@ -246,8 +286,7 @@
        }
        // Our window buffer is now full. Replace smallest with anything
        // larger
        // and re-heapify
        // larger and re-heapify
        for (int i = appendLength; i < etimes.size(); i++)
        {
          if (etimes.get(i) > array.get(0))
@@ -314,7 +353,22 @@
        {
          strings[i++] = column;
        }
        printer.printRow(strings);
        if (printer != null)
        {
          printer.printRow(strings);
        }
        else
        {
          // Script-friendly.
          app.getOutputStream().print(averageDuration);
          for (String s : strings)
          {
            app.getOutputStream().print(",");
            app.getOutputStream().print(s);
          }
          app.getOutputStream().println();
        }
      }
    }
opendj-sdk/sdk/src/com/sun/opends/sdk/tools/SearchRate.java
@@ -261,6 +261,8 @@
  private BooleanArgument verbose;
  private BooleanArgument scriptFriendly;
  private final AtomicInteger entryRecentCount = new AtomicInteger();
@@ -340,7 +342,7 @@
  @Override
  public boolean isScriptFriendly()
  {
    return false;
    return scriptFriendly.isPresent();
  }
@@ -434,6 +436,11 @@
          INFO_DESCRIPTION_VERBOSE.get());
      verbose.setPropertyName("verbose");
      argParser.addArgument(verbose);
      scriptFriendly = new BooleanArgument("scriptFriendly", 'S',
          "scriptFriendly", INFO_DESCRIPTION_SCRIPT_FRIENDLY.get());
      scriptFriendly.setPropertyName("scriptFriendly");
      argParser.addArgument(scriptFriendly);
    }
    catch (final ArgumentException ae)
    {