aboutsummaryrefslogtreecommitdiffstats
path: root/assemble_files.py
blob: f4be48f676006a0a64475c5fb9fe8020e6f77737 (plain) (blame)
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
#!/usr/bin/env python

import sys

from plot import decode
from os.path  import splitext, basename

from glob import glob
from collections import defaultdict

#G-EDF/testpoint_ucap=13.75_wss=1792_dist=exp-10-10-100_deadlines=implicit_host=ludwig_scheduler=G-EDF.csv

def key(fname):
    name, ext = splitext(basename(fname))
    conf = decode(name)
    if 'quanta' in conf:
        q = '_quanta=%s' % conf['quanta']
    else:
        q = ''
    s  = 'scheduler=%s'  % conf['scheduler']
    d  = 'dist=%s'  % conf['dist']
    dl = 'deadlines=%s' % conf['deadlines']
    h  = 'host=%s'  % conf['host']

    return '_'.join([d, dl, s, h]) + q

def assemble_results(dir):
    files = glob(dir + '/*.csv')

    parts = defaultdict(list)

    for f in files:
        k = key(f)
        parts[k].append(f)

    for i, k in enumerate(parts):
        comment = 1
        print '[%d/%d] Processing %s' % (i+ 1, len(parts), k)
        out = open('sched_%s.csv' % k, 'w')
        for f in sorted(parts[k]):
            for line in open(f):
                if line[0] != '#' or comment:
                    out.write(line)
                    if line[0] == '#':
                        comment -= 1
        out.close()



if __name__ == '__main__':
    for d in sys.argv[1:]:
        assemble_results(d)