Works on this device
API Latency Percentile Calculator
Paste the response times of an API and see its percentiles. Choose how the percentile is worked out, because monitoring tools do not all use the same method. The tool also gives the mean, the shortest and longest time, the share under a target and a histogram.
Enter your values
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Fill in the values, then choose Calculate.
Your result
How it was worked out
How to use this calculator
- Paste the latencies, one for each request, separated by commas, spaces or new lines. Choose the unit (µs, ms or s).
- Choose the percentile method. Use the one of your monitoring tool if you want to compare with it.
- Type other percentiles if you need them, such as 75 or 99.99, and a target such as 200 ms to see the share of requests at or below it.
- Choose Calculate. The tables give every percentile with the place used in the sorted list, and the histogram.
The three methods
Sort the n values from the shortest to the longest: x1, x2, ..., xn.
- Nearest rank: rank = p ÷ 100 × n, rounded up (at least 1). The percentile is the value at that rank, so it is always a time that a real request had.
- Linear interpolation, (n − 1) basis: h = (n − 1) × p ÷ 100 + 1. The percentile lies between the values at places ⌊h⌋ and ⌊h⌋ + 1, in proportion to the decimal part of h. This is the method of Excel PERCENTILE.INC and the default of NumPy.
- Linear interpolation, (n + 1) basis: h = (n + 1) × p ÷ 100, with the same interpolation. It is defined only when h is from 1 to n, so p99 needs at least 99 values and p99.9 at least 999. This is the method of Excel PERCENTILE.EXC.
- Mean = sum ÷ n. Standard deviation is the sample one (it divides by n − 1).
Worked example
The example has 20 requests. Sorted, the 10th is 118 ms, the 18th is 143 ms, the 19th is 250 ms and the 20th is 880 ms. By nearest rank, p50 = 118 ms (rank 10), p90 = 143 ms (rank 18), p95 = 250 ms (rank 19) and p99 = 880 ms (rank 20). The mean is 161.7 ms, pulled up by the one slow request of 880 ms.
With interpolation on the (n − 1) basis, p50 is halfway between the 10th and 11th values: h = 19 × 0.5 + 1 = 10.5, so p50 = 119 ms. 18 of the 20 requests (90%) took 200 ms or less.
Limits you should know
- High percentiles of a small sample are set by one or two requests. p99 of 20 requests is simply the slowest one.
- Do not average the percentiles of different periods or servers. Put all the values together and work them out again.
- The tool does not measure your API. It works with the times you paste, in this browser.
- Use p99 to set a timeout above the slow but healthy requests with the Request Timeout Calculator. For availability targets, use the API Availability Calculator.