THINK FIRST·CODE LATER

← All labs

DORA metrics from a deployment log

Problem

Compute the four DORA metrics for StudyBuddy from its deployment log.

Input: first line days n — the length of the period in days and the number of deployments. Then n lines, each:

leadTimeHours result [restoreMinutes]

where result is OK or FAIL; a FAIL line has a third number, the minutes needed to restore service.

Print:

Deployments: n
Deployment frequency: X per week
Average lead time: Y hours
Change failure rate: Z%
Mean time to restore: W minutes
  • frequency = n * 7 / days, two decimals;
  • average lead time: two decimals (0.00 if n is 0);
  • change failure rate: failures × 100 / n, one decimal (0.0 if n is 0);
  • mean time to restore: average of the restore minutes of the failures, one decimal, or n/a if there were no failures.

Input:

14 5
2 OK
4 OK
1 FAIL 90
3 OK
5 FAIL 30

Output:

Deployments: 5
Deployment frequency: 2.50 per week
Average lead time: 3.00 hours
Change failure rate: 40.0%
Mean time to restore: 60.0 minutes

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.

s2-3-data-1.txt

14 5
2 OK
4 OK
1 FAIL 90
3 OK
5 FAIL 30
What your program must print for s2-3-data-1.txt
Deployments: 5
Deployment frequency: 2.50 per week
Average lead time: 3.00 hours
Change failure rate: 40.0%
Mean time to restore: 60.0 minutes

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 < s2-3-data-1.txt

Windows PowerShell does not understand <:

Get-Content s2-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.