1#!/usr/bin/python
2import sys, os, re
3
4def avg_deviation(values):
5    sum = 0
6    count = 0
7
8    if not values:
9        return (0, 0)
10    for x in values:
11        sum += x
12        count += 1
13    average = sum / count
14    sum_sq_dev = 0
15    for x in values:
16        sum_sq_dev += (x - average) ** 2
17    std_dev = (sum_sq_dev / count)**0.5
18    return (average, 100 * std_dev / average)
19
20
21list = []
22for line in sys.stdin.readlines():
23    (user, system, elapsed, cpu) = line.split()[0:4]
24    user = float(re.match(r'([\d\.]+)', user).group(0))
25    system = float(re.match(r'([\d\.]+)', system).group(0))
26    m = re.match(r'(\d+):([\d\.]+)', elapsed)
27    elapsed = 60*int(m.group(1)) + float(m.group(2))
28    cpu = int(re.match(r'(\d+)', cpu).group(0))
29
30    list.append((user, system, elapsed, cpu))
31
32print "   user: %0.2fs (%0.2f%%)" % avg_deviation([x[0] for x in list])
33print " system: %0.2fs (%0.2f%%)" % avg_deviation([x[1] for x in list])
34print "elapsed: %0.2fs (%0.2f%%)" % avg_deviation([x[2] for x in list])
35print "    cpu: %d%% (%0.2f%%)" % avg_deviation([x[3] for x in list])
36