Class PercentileTracker

java.lang.Object
org.mockserver.mock.drift.PercentileTracker

public class PercentileTracker extends Object
Sliding window p50/p95 tracker for response times per expectation ID. Uses a fixed-size circular buffer per expectation. Thread-safe via ConcurrentHashMap.compute(Object, java.util.function.BiFunction).
  • Constructor Details

    • PercentileTracker

      public PercentileTracker(int windowSize)
  • Method Details

    • getInstance

      public static PercentileTracker getInstance()
    • record

      public void record(String expectationId, long responseTimeMs)
      Record a response time observation for the given expectation ID.
    • p50

      public long p50(String expectationId)
      Returns:
      the p50 (median) response time for the given expectation, or 0 if no data.
    • p95

      public long p95(String expectationId)
      Returns:
      the p95 response time for the given expectation, or 0 if no data.
    • count

      public int count(String expectationId)
      Returns:
      the number of observations recorded for the given expectation.
    • clear

      public void clear()
      Clears all tracked data.