SampleComparator (Apache JMeter dist API)
Description: declaration: package: org.apache.jmeter.report.core, interface: SampleComparator

Package org.apache.jmeter.report.core

# Interface SampleComparator

All Known Implementing Classes:
  `FieldSampleComparator`

public interface SampleComparator
Defines a comparator for `Sample` instances

Since:
  3.0

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `compare(Sample s1, Sample s2)`
  Compares to sample
  `void`
  `initialize(SampleMetadata metadata)`
  Initializes the comparator with the `SampleMetadata` of the samples to be compared.

- ## Method Details

  - ### compare

    long compare(Sample s1, Sample s2)
    Compares to sample

    Must return an long integer that define the relational order of the 2 compared samples:

    - Negative long integer : s1 is lower than s2
    - Zero long integer : s1 is strictly equal to s2
    - Positive long integer : s1 is greater than s2
    Parameters:
      `s1` - The first sample to be compared
      `s2` - The second sample to compared
    Returns:
      A negative is `s1 < s2`, `0 if s1 = s2`, a positive integer if `s1 > s2`

  - ### initialize

    void initialize(SampleMetadata metadata)
    Initializes the comparator with the `SampleMetadata` of the samples to be compared.

    This function is invoked before any call to the`compare` service.

    Not that this function is the place to get sample column indexes for better performance

    Parameters:
      `metadata` - The metadata of the sample to be compared by this instance