Class BenchmarkData

java.lang.Object
com.github.rlacher.sortbench.benchmark.data.BenchmarkData

public final class BenchmarkData extends Object
Represents benchmark data for sorting algorithms, encapsulating the data array and its type.

This class ensures immutability by creating copies of the input data.

  • Constructor Details

    • BenchmarkData

      public BenchmarkData(int[] data, BenchmarkData.DataType type)
      Constructor for creating a BenchmarkData object.

      This constructor creates a copy of the data array to avoid external modification.

      Parameters:
      data - The data array to be stored (a copy is created).
      type - The type of the data.
      Throws:
      IllegalArgumentException - If the data array is null.
    • BenchmarkData

      public BenchmarkData(BenchmarkData other)
      Copy constructor for creating a BenchmarkData object from another BenchmarkData object.
      Parameters:
      other - The other BenchmarkData object to copy from.
      Throws:
      IllegalArgumentException - If the other BenchmarkData object or its data array is null.
  • Method Details

    • getData

      public int[] getData()
      Getter for the data array.
      Returns:
      Returns the same instance of the data array (no copying).
    • getLength

      public int getLength()
      Returns the length of the data array.

      Benchmark data of various lengths are required for performance assessment of the sorting algorithms.

      Returns:
      The length of the data array.
    • getType

      public BenchmarkData.DataType getType()
      Returns the type of the data.

      Benchmark data of various types help assess the performance of sorting algorithms.

      Returns:
      The type of the data array.
    • toString

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