#K41607. Process Log Latencies
Process Log Latencies
Process Log Latencies
You are given a series of log entries, each in the format: (timestamp\ service_name\ latency), where:
- timestamp is in HH:MM:SS format.
- service_name is a string identifying the service.
- latency is an integer representing the latency in milliseconds.
Your task is to compute two quantities:
- A JSON dictionary containing the total latency for each service.
- The service that recorded the highest single latency.
Input is provided line by line via standard input. The log entries end when a line containing only the word "end" is encountered. If no logs are provided (i.e. the first line is "end"), output an empty dictionary and None for the highest latency service.
inputFormat
Input is read from standard input and consists of multiple lines. Each line (except the terminating line) is formatted as follows:
(timestamp\ service_name\ latency)
- timestamp: A string in HH:MM:SS format.
- service_name: A string without spaces.
- latency: An integer (in milliseconds).
outputFormat
The output should be printed to standard output and consists of two lines:
- A JSON dictionary (as a single line) representing the total latencies for each service.
- A single line containing the name of the service with the highest single log latency. Print
None
if there are no logs.
15:32:10 serviceA 120
15:32:15 serviceB 80
15:32:20 serviceA 150
15:32:30 serviceC 200
15:32:35 serviceB 50
15:32:40 serviceC 100
15:32:45 serviceA 250
end
{"serviceA": 520, "serviceB": 130, "serviceC": 300}
serviceA
</p>