summaryrefslogtreecommitdiffstats
path: root/data/process.py
blob: 562a5d2748a43460f4b32346a7fc3de46216e8bb (plain)
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
#!/usr/bin/env python3

import re
import sys
from itertools import groupby

test_re = re.compile(r"^Test[ ]([0-9]+):[ ](.*)$")

def parse_file_z(_file):
    """Take a file and return all numbers corresponding to failures."""
    r = []

    with open(_file, "r") as f:
        lines = f.readlines()

    for l in lines:
        match = test_re.match(l)
        if match is None:
            continue
        value = match.group(2)
        if value == "TIM":
            r.append(int(match.group(1)))

    return sorted(r)


def parse_file_l(_file):
    """Take a file consisting of lists of failures and return them all."""
    r = []

    with open(_file, "r") as f:
        lines = f.readlines()

    for l in lines:
        r.append(int(l))

    return sorted(r)


def find_common(ls):
    """Finds all common elements."""
    d = {}
    for i in range(1, 6701):
        ret = list(map(lambda x: i in x, ls))
        if any(ret):
            d[i] = ret

    return d


def group_up(d):
    """Group up all the elements."""
    sorted_values = sorted(d.values())
    for key, value in groupby(sorted_values):
        print((len(list(value)), key), end = " ")
    print()


def main():
    vivado191 = parse_file_z("./vivado191.txt")
    intel = parse_file_z("./intel.txt")
    legup = parse_file_z("./legup.txt")
    bambu = parse_file_l("./bambu_timeout.txt")

    common = find_common([vivado191, intel, legup, bambu])
    group_up(common)


if __name__ == "__main__":
    main()