THINK FIRST·CODE LATER

← All labs

Load-test report with percentiles

Problem

Analyse the results of a StudyBuddy load test.

Input: first line durationSeconds sloP95Ms maxErrorPercent. Then lines, one per request: either a response time in milliseconds (a positive integer) or the word ERROR (the request failed), until the end of input.

Compute, over the successful requests (use the nearest-rank method for percentiles: the value at position ⌈p/100 × n⌉ in the sorted list):

Requests: total (ok successful, e errors)
Throughput: x.xx req/s            (total requests / duration)
Mean: x.x ms
p50: v ms
p95: v ms
p99: v ms
Max: v ms
Error rate: x.x%
Concurrency (Little): x.xx        (throughput * mean in seconds)
SLO p95 <= S ms: PASS|FAIL
Errors <= E%: PASS|FAIL

If there are no successful requests, print No successful requests instead of the lines from Mean to Max, then the rest, with Concurrency (Little): 0.00 and SLO ... : FAIL.

Input:

10 300 5
120
80
95
ERROR
200
150
110
90
400
130

Output:

Requests: 10 (9 successful, 1 errors)
Throughput: 1.00 req/s
Mean: 152.8 ms
p50: 120 ms
p95: 400 ms
p99: 400 ms
Max: 400 ms
Error rate: 10.0%
Concurrency (Little): 0.15
SLO p95 <= 300 ms: FAIL
Errors <= 5%: FAIL

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.