forked from gallir/concurrencia
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsummary.py
More file actions
executable file
·94 lines (79 loc) · 2.44 KB
/
Copy pathsummary.py
File metadata and controls
executable file
·94 lines (79 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#! /usr/bin/python
import sys
import re
import argparse
logs = {}
algorithms = []
def main():
#print("\t")
for l in configuration.filenames:
author = l[9:]
author = author.replace(".log", "")
#print(author)
log = logs[author] = {}
log["alg"] = {}
log["real"] = {}
log["cores"] = {}
LOG = open(l)
for line in LOG:
r = alginfo(line)
if r:
alg = log["alg"][r] = []
real = log["real"][r] = []
if r not in algorithms:
algorithms.append(r)
#print algorithms
r = times(line)
if r:
alg.append(r[1] + r[2])
real.append(r[0])
#print alg
r = cpuinfo(line, "physical id")
if r != None:
cpu_id = r
r = cpuinfo(line, "siblings")
if r != None:
if not cpu_id in log["cores"]:
log["cores"][cpu_id] = r
#print log["cores"]
LOG.close()
for a in algorithms:
print("\t%s" % (a,)),
print("\tcores")
for author in logs.keys():
l = logs[author]
print("%s" % (author)),
for a in algorithms:
try:
if configuration.real:
print("\t%5.3f" % (sum(l["real"][a])/len(l["real"][a]),)),
else:
print("\t%5.3f" % (sum(l["alg"][a])/len(l["alg"][a]),)),
except:
print("\t0"),
print("\t%d" % (sum(l["cores"].values())))
def cpuinfo(line, field):
r = re.match(re.escape(field) + '\s*:\s*(\d+)', line)
if r:
return int(r.group(1))
return None
def alginfo(line):
r = re.match(r'-- \[(.+?)\] --', line)
if r:
return r.group(1)
return None
def times(line):
r = re.match(r'\s*times: +real +\d:([\d\.]+), +user +([\d\.]+), +sys ([\d\.]+)', line)
if not r:
r = re.match(r'\s*real\s+0m([\d\.]+)s\s+user\s+0m([\d\.]+)s\s+sys\s+0m([\d\.]+)s', line)
if r:
times = r.group(1, 2, 3)
times = [float(x) for x in times]
return times
return None
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--real", "-r", action="store_true", help="Clocki times")
parser.add_argument('filenames', nargs='*')
configuration = parser.parse_args()
main()