Class BenchmarkContext

java.lang.Object
com.github.rlacher.sortbench.results.BenchmarkContext
All Implemented Interfaces:
Comparable<BenchmarkContext>

public final class BenchmarkContext extends Object implements Comparable<BenchmarkContext>
Represents the contextual parameters of a benchmark run.

This class encapsulates the data type, data length, and sorting algorithm used during a benchmark execution. Instances of this class are used to create BenchmarkResult and AggregatedResult objects.

This class is immutable, ensuring that context parameters cannot be modified after creation.

  • Constructor Details

    • BenchmarkContext

      public BenchmarkContext(BenchmarkData.DataType dataType, int dataLength, String sortStrategyName)
      Constructs a new BenchmarkContext object.
      Parameters:
      dataType - The type of input data.
      dataLength - The length of the input data.
      sortStrategyName - The name of the sorting strategy.
      Throws:
      IllegalArgumentException - If dataType or sortStrategyName are null, or dataLength is negative.
  • Method Details

    • getDataType

      public BenchmarkData.DataType getDataType()
      Gets the data type.
      Returns:
      The data type.
    • getDataLength

      public int getDataLength()
      Gets the data length.
      Returns:
      The data length.
    • getSortStrategyName

      public String getSortStrategyName()
      Gets the sort strategy name.
      Returns:
      The sort strategy name.
    • toString

      public String toString()
      Returns a string representation of the BenchmarkContext object.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the object.
    • equals

      public boolean equals(Object obj)
      Indicates whether some other object is "equal to" this one.
      Overrides:
      equals in class Object
      Parameters:
      obj - The object with which to compare.
      Returns:
      true if this object is the same as the obj argument; false otherwise.
    • hashCode

      public int hashCode()
      Returns a hash code value for the object.
      Overrides:
      hashCode in class Object
      Returns:
      A hash code value for this object.
    • compareTo

      public int compareTo(BenchmarkContext other)
      Compares this BenchmarkContext for order: dataType, dataLength, sortStrategyName.
      Specified by:
      compareTo in interface Comparable<BenchmarkContext>
      Parameters:
      other - The BenchmarkContext to be compared with.
      Returns:
      Negative, zero, or positive integer for less, equal, or greater.
      Throws:
      IllegalArgumentException - If other is null.