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

Data for this lab

Your program reads its data from standard input. Download the file, then give it to your program as shown below. Start with data set 1: its expected output is given.

s9-3-data-1.txt

10 300 5
120
80
95
ERROR
200
150
110
90
400
130
What your program must print for s9-3-data-1.txt
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

Run your program first, then open this and compare line by line: your output must contain these lines exactly.

How to give the file to my program

Terminal (macOS, Linux, or Windows Command Prompt), after compiling:

java Main < s9-3-data-1.txt

Windows PowerShell does not understand <:

Get-Content s9-3-data-1.txt | java Main

IntelliJ IDEA: Run → Edit Configurations → Redirect input from. Or simply paste the content of the file into the console when the program waits for input.

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.