Class Perf

java.lang.Object
io.nosqlbench.nb.api.testutils.Perf
All Implemented Interfaces:
Iterable<Result>

public class Perf extends Object implements Iterable<Result>
Perf is a testing utility class that collects and analyzes performance data from individual test runs.
  • Constructor Details

    • Perf

      public Perf(String description)
  • Method Details

    • getDeltas

      public double[] getDeltas(Function<Result,Double> resultProperty)
      Get the differences between successive test runs for a given property. The values provided have the same size as the results, but the first result will always be Double.NaN. This makes it easy to takeUpTo the results in tabular form and display them "as of" a given result index.
      Parameters:
      resultProperty - A function that yields a double from a Result
      Returns:
      an array of deltas of that property
    • add

      public Perf add(Result result)
      Add a test result to this performance collector.
      Parameters:
      result - a Result object
      Returns:
      this Perf, for method chaining
    • add

      public Perf add(String description, long start, long end, long ops)
      Add a test result to this performance collector.
      Parameters:
      description - A description of the result
      start - The start time of the test run
      end - The end time of the test run
      ops - The total number of iterations of the test run
      Returns:
      this Perf, for method chaining
    • isConverged

      public boolean isConverged(Function<Result,Double> resultProperty, double withinMargin, int count)
      Extract the double field value from the last results and return whether or not they are within some fractional margin between the minimum and maximum seen value.
      Parameters:
      resultProperty - A function to extract the double field value
      withinMargin - A value like 0.01f to represent "10 percent"
      count - The number of recent results that must be present
      Returns:
      true if there are at least count results, and the min and max values are within that margin
    • getMaximumDelta

      public double getMaximumDelta(Function<Result,Double> resultProperty, int count)
      For the most recent test runs, measure the maximum difference in a given property.
      Parameters:
      resultProperty - A function that produces a property from a Result
      count - The number of recent test runs to consider
      Returns:
      The difference between the min and max values of the property
    • sort

      public Perf sort(Function<Result,Double> resultProperty)
      Sort the internal results according to some property
      Parameters:
      resultProperty - A function that produces a property from a Result
      Returns:
      this Perf, for method chaining
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toStringDelta

      public String toStringDelta(Function<Result,Double> resultProperty, String deltaDescription, int... lastN)
      Summarize the last results in a tabular format, with row-by-row delta included for a given property.
      Parameters:
      resultProperty - A function that extracts a property from a Result
      deltaDescription - The description of the delta column
      lastN - The number of recent test runs to include
      Returns:
      A tabular representation of the test runs and the deltas for the property
    • getLastResult

      public Result getLastResult()
      Returns:
      Returns the last result
    • reduceConcurrent

      public Perf reduceConcurrent()
      Reduce a number of independent and concurrent runs into a single summary.
      Returns:
      A Perf with a single result
    • iterator

      public Iterator<Result> iterator()
      Specified by:
      iterator in interface Iterable<Result>
    • start

      public Perf.Time start(String name, long ops)