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

Ludovic Poitou
04.13.2010 d692e4398b8e742b765dc332eefc3020ae2de191
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
108 ■■■■ changed files
sdk/src/com/sun/opends/sdk/tools/AuthRate.java 12 ●●●●● patch | view | raw | blame | history
sdk/src/com/sun/opends/sdk/tools/ModRate.java 9 ●●●● patch | view | raw | blame | history
sdk/src/com/sun/opends/sdk/tools/PerformanceRunner.java 78 ●●●● patch | view | raw | blame | history
sdk/src/com/sun/opends/sdk/tools/SearchRate.java 9 ●●●● patch | view | raw | blame | history
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)
    {
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)
    {
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,8 +115,20 @@
        }
      }
      this.percentiles = pSet.descendingSet();
      numColumns = 5 + this.percentiles.size() + additionalColumns.length
      this.numColumns = 5 + this.percentiles.size() + additionalColumns.length
          + (isAsync ? 1 : 0);
      this.beans = ManagementFactory.getGarbageCollectorMXBeans();
    }
    @Override
    public void run()
    {
      final MultiColumnPrinter printer;
      if (!app.isScriptFriendly())
      {
      printer = new MultiColumnPrinter(numColumns, 2, "-",
          MultiColumnPrinter.RIGHT, app);
      printer.setTitleAlign(MultiColumnPrinter.RIGHT);
@@ -156,15 +171,40 @@
      span = new int[numColumns];
      Arrays.fill(span, 1);
      printer.addTitle(title, span);
      beans = ManagementFactory.getGarbageCollectorMXBeans();
    }
    @Override
    public void run()
    {
      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,8 +353,23 @@
        {
          strings[i++] = column;
        }
        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();
        }
      }
    }
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)
    {