# How to figure out that 95 pecentile of time calls came back within certain milliseconds

I am working on a project in which I am supposed to do profiling on our REST Service. And after that figure it out how much is the 90 percentile or 95 percentile of our service. Meaning how much time calls is taking in 90% of time or 95% percent of time

Below is the histogram I have created by profiling my service-

0 came back between 1 and 2 ms
0 came back between 3 and 4 ms
0 came back between 5 and 8 ms
0 came back between 9 and 16 ms
0 came back between 17 and 32 ms
2205 came back between 33 and 64 ms
141 came back between 65 and 128 ms
50 came back greater than 128 ms


From the above histogram it means, 2205 calls came back between 33 and 64 ms, 141 calls came back between 65 and 128 ms.

So now I am trying to figure out how to calculate what is the 90 percentile or 95 percentile of this? Means 90 percentage of time calls came back in how many milliseconds?

I have a map as well for the above histogram, if we cannot figure out this percentile from the above histogram, then we can use this Map as well.

From this Map only, I am creating above histogram-

{213=1, 114=2, 185=1, 131=1, 40=145, 67=8, 49=35, 537=2, 164=1, 565=1, 55=13, 96=1, 546=1, 117=1, 68=10, 62=6, 83=1, 34=333, 41=108, 179=1, 48=48, 111=1, 129=1, 69=11, 33=1, 173=1, 61=8, 541=1, 74=7, 180=2, 42=78, 47=46, 56=11, 84=2, 70=12, 228=1, 273=1, 46=52, 102=1, 225=1, 81=2, 181=1, 563=1, 549=1, 137=1, 73=3, 235=1, 53=17, 90=1, 36=190, 118=1, 45=78, 35=267, 72=9, 63=16, 54=11, 271=1, 189=1, 209=1, 175=4, 51=23, 203=2, 37=186, 58=5, 196=2, 237=1, 86=3, 44=81, 64=15, 92=3, 224=1, 71=8, 251=1, 52=12, 78=3, 43=75, 147=1, 133=1, 580=1, 57=11, 263=1, 566=1, 85=1, 243=1, 38=161, 559=1, 80=3, 132=1, 194=1, 107=6, 65=5, 183=1, 222=1, 93=1, 60=12, 231=1, 94=1, 66=12, 122=1, 39=135, 50=35, 76=1, 59=6, 104=1, 158=1, 113=1, 204=1, 87=1, 115=2}

In the above map, key is the number of milliseconds and value is total number of calls So for example -

213=1

It means, 1 call came back in 213 milliseconds.

114=2

2 calls came back in 114 milliseconds.

Can anyone help me with this? Either I can create the percentile stuff from the histogram or the above Map as well.

I believe its a simple Mathematics stuff.

-

The histogram is too coarse grained to give reliable information about the $95$th percentile. By accident, it is pretty good for the $98$th.

The needed data are almost certainly in the Map, though the order there is not clear.

Find the total number of calls. From the histogram, the number is $2396$.

Let us suppose it is $2400$.

For the $98$th percentile, note that $2\%$ of $2400$ is $48$. Count backwards from the largest waiting time until you get to a time that has $48$ waiting times, counting multiplicities, that are larger than it. The associated time will be the $98$-th percentile. From the histogram, it looks as if that number is a small amount above $128$ ms.

For the $95$th percentile, note that $5\%$ of $2400$ is $120$. So find the place that has $120$ of the wait times, counting multiplicities, above it. The answer will be somewhere between $65$ ms and $128$ ms, probably quite a bit closer to $65$ than to $128$. But to pin it down precisely, you really do need to use the more detailed information.

-