src/main/java/org/apache/datasketches/characterization/filters/BaseFilterUpdateSpeedProfile.java [95:172]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            final int nextU = lastU == 0 ? minU : (int)pwr2SeriesNext(uPPO, lastU);
            lastU = nextU;
            final int trials = getNumTrials(nextU);


            System.gc(); //much slower but cleaner plots
            double sumUpdateTimePerU_nS = 0;
            for (int t = 0; t < trials; t++) {
                sumUpdateTimePerU_nS += doTrial(nextU);
            }
            final double meanUpdateTimePerU_nS = sumUpdateTimePerU_nS / trials;

            process(meanUpdateTimePerU_nS, trials, nextU, dataStr, numSketches);

            job.println(dataStr.toString());
        }
    }

    /**
     * Computes the number of trials for a given current number of uniques for a
     * trial set. This is used in speed trials and decreases the number of trials
     * as the number of uniques increase.
     *
     * @param curU the given current number of uniques for a trial set.
     * @return the number of trials for a given current number of uniques for a
     * trial set.
     */
    private int getNumTrials(final int curU) {
        final int minBpU = 1 << lgMinBpU;
        final int maxBpU = 1 << lgMaxBpU;
        final int maxT = 1 << lgMaxT;
        final int minT = 1 << lgMinT;
        if (lgMinT == lgMaxT || curU <= minBpU) {
            return maxT;
        }
        if (curU >= maxBpU) {
            return minT;
        }
        final double lgCurU = log(curU) / LN2;
        final double lgTrials = slope * (lgCurU - lgMinBpU) + lgMaxT;
        return (int) pow(2.0, lgTrials);
    }

    /**
     * Process the results
     *
     * @param meanUpdateTimePerSet_nS mean update time per update set in nanoseconds.
     * @param uPerTrial number of uniques per trial
     * @param sb The StringBuilder object that is reused for each row of output
     * @param numSketches the number of sketches per set.
     */
    private static void process(final double meanUpdateTimePerSet_nS, final int trials,
                                final int uPerTrial, final StringBuilder sb, final int numSketches) {
        // OUTPUT
        sb.setLength(0);
        sb.append(uPerTrial).append(TAB);
        sb.append(trials).append(TAB);
        sb.append(meanUpdateTimePerSet_nS);
        if (numSketches > 1) {
            sb.append(TAB);
            sb.append(meanUpdateTimePerSet_nS / numSketches);
        }
    }

    /**
     * Returns a column header row
     * @return a column header row
     */
    private String getHeader() {
        final StringBuilder sb = new StringBuilder();
        sb.append("InU").append(TAB);
        sb.append("Trials").append(TAB);
        sb.append("nS/Set");
        if (numSketches > 1) {
            sb.append(TAB);
            sb.append("nS/Sketch");
        }
        return sb.toString();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



src/main/java/org/apache/datasketches/characterization/uniquecount/BaseUpdateSpeedProfile.java [98:174]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      final int nextU = lastU == 0 ? minU : (int)pwr2SeriesNext(uPPO, lastU);
      lastU = nextU;
      final int trials = getNumTrials(nextU);

      System.gc(); //much slower but cleaner plots
      double sumUpdateTimePerU_nS = 0;
      for (int t = 0; t < trials; t++) {
        sumUpdateTimePerU_nS += doTrial(nextU);
      }
      final double meanUpdateTimePerU_nS = sumUpdateTimePerU_nS / trials;

      process(meanUpdateTimePerU_nS, trials, nextU, dataStr, numSketches);

      job.println(dataStr.toString());
    }
  }

  /**
   * Computes the number of trials for a given current number of uniques for a
   * trial set. This is used in speed trials and decreases the number of trials
   * as the number of uniques increase.
   *
   * @param curU the given current number of uniques for a trial set.
   * @return the number of trials for a given current number of uniques for a
   * trial set.
   */
  private int getNumTrials(final int curU) {
    final int minBpU = 1 << lgMinBpU;
    final int maxBpU = 1 << lgMaxBpU;
    final int maxT = 1 << lgMaxT;
    final int minT = 1 << lgMinT;
    if (lgMinT == lgMaxT || curU <= minBpU) {
      return maxT;
    }
    if (curU >= maxBpU) {
      return minT;
    }
    final double lgCurU = log(curU) / LN2;
    final double lgTrials = slope * (lgCurU - lgMinBpU) + lgMaxT;
    return (int) pow(2.0, lgTrials);
  }

  /**
   * Process the results
   *
   * @param meanUpdateTimePerSet_nS mean update time per update set in nanoseconds.
   * @param uPerTrial number of uniques per trial
   * @param sb The StringBuilder object that is reused for each row of output
   * @param numSketches the number of sketches per set.
   */
  private static void process(final double meanUpdateTimePerSet_nS, final int trials,
      final int uPerTrial, final StringBuilder sb, final int numSketches) {
    // OUTPUT
    sb.setLength(0);
    sb.append(uPerTrial).append(TAB);
    sb.append(trials).append(TAB);
    sb.append(meanUpdateTimePerSet_nS);
    if (numSketches > 1) {
      sb.append(TAB);
      sb.append(meanUpdateTimePerSet_nS / numSketches);
    }
  }

  /**
   * Returns a column header row
   * @return a column header row
   */
  private String getHeader() {
    final StringBuilder sb = new StringBuilder();
    sb.append("InU").append(TAB);
    sb.append("Trials").append(TAB);
    sb.append("nS/Set");
    if (numSketches > 1) {
      sb.append(TAB);
      sb.append("nS/Sketch");
    }
    return sb.toString();
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



