Class Perf

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

public class Perf
extends java.lang.Object
implements java.lang.Iterable<Result>
Perf is a testing utility class that collects and analyzes performance data from individual test runs.
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  Perf.Time  
  • Constructor Summary

    Constructors 
    Constructor Description
    Perf​(java.lang.String description)  
  • Method Summary

    Modifier and Type Method Description
    Perf add​(Result result)
    Add a test result to this performance collector.
    Perf add​(java.lang.String description, long start, long end, long ops)
    Add a test result to this performance collector.
    double[] getDeltas​(java.util.function.Function<Result,​java.lang.Double> resultProperty)
    Get the differences between successive test runs for a given property.
    Result getLastResult()  
    double getMaximumDelta​(java.util.function.Function<Result,​java.lang.Double> resultProperty, int count)
    For the most recent test runs, measure the maximum difference in a given property.
    boolean isConverged​(java.util.function.Function<Result,​java.lang.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.
    java.util.Iterator<Result> iterator()  
    Perf reduceConcurrent()
    Reduce a number of independent and concurrent runs into a single summary.
    Perf sort​(java.util.function.Function<Result,​java.lang.Double> resultProperty)
    Sort the internal results according to some property
    Perf.Time start​(java.lang.String name, long ops)  
    java.lang.String toString()  
    java.lang.String toStringDelta​(java.util.function.Function<Result,​java.lang.Double> resultProperty, java.lang.String deltaDescription, int... lastN)
    Summarize the last results in a tabular format, with row-by-row delta included for a given property.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • Perf

      public Perf​(java.lang.String description)
  • Method Details

    • getDeltas

      public double[] getDeltas​(java.util.function.Function<Result,​java.lang.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​(java.lang.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​(java.util.function.Function<Result,​java.lang.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​(java.util.function.Function<Result,​java.lang.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​(java.util.function.Function<Result,​java.lang.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 java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • toStringDelta

      public java.lang.String toStringDelta​(java.util.function.Function<Result,​java.lang.Double> resultProperty, java.lang.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 java.util.Iterator<Result> iterator()
      Specified by:
      iterator in interface java.lang.Iterable<Result>
    • start

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