This question evaluates understanding of concurrent data structures, thread-safety, time-windowed metrics aggregation, and percentile computation for latency tracking within the Software Engineering Fundamentals domain.
Design a thread-safe LatencyTracker class that supports:
timestamp
(e.g., epoch millis) and
latencyMs
(integer milliseconds)
addSample(timestamp, latencyMs)
[startTimestamp, endTimestamp]
(inclusive)
p
is in
(0, 100]
(e.g., 50, 90, 95, 99)
getPercentile(startTimestamp, endTimestamp, p)
p
among samples whose timestamps fall inside the window.
Additional requirements:
addSample
) and readers (
getPercentile
).