source: tools/perf/process_stat_array.py @ 2bfee8e

ADTast-experimentalenumforall-pointer-decaypthread-emulationqualifiedEnum
Last change on this file since 2bfee8e was b1a2c4a, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

Added first attempt at processing array

  • Property mode set to 100755
File size: 2.7 KB
Line 
1#!/usr/bin/python3
2
3import argparse, os, sys, re
4
5def dir_path(string):
6    if os.path.isdir(string):
7        return string
8    else:
9        raise NotADirectoryError(string)
10
11parser = argparse.ArgumentParser()
12parser.add_argument('--path', type=dir_path, default=".cfadata", help= 'paste path to biog.txt file')
13
14try :
15        args = parser.parse_args()
16except NotADirectoryError:
17        print("Must use option --path to existing directory or have .cfadata in current directory", file=sys.stderr)
18        sys.exit(1)
19
20root, _, filenames = next(os.walk(args.path))
21
22merged = []
23counters = {}
24
25#open the files
26for filename in filenames:
27        try:
28                m = re.search('[A-z]+0x([0-9a-f]+)\.data', filename)
29                me = m.group(1)
30                counters[me] = 0
31                with open(os.path.join(root, filename), 'r') as file:
32                        for line in file:
33                                # data = [int(x.strip()) for x in line.split(',')]
34                                data = [int(line.strip())]
35                                data = [me, *data]
36                                merged.append(data)
37
38        except:
39                pass
40
41
42# Sort by timestamp (the second element)
43# take second element for sort
44def takeSecond(elem):
45    return elem[1]
46
47merged.sort(key=takeSecond)
48
49# for m in merged:
50#       print(m)
51
52single = []
53curr = 0
54
55# merge the data
56# for (me, time, value) in merged:
57for (me, value) in merged:
58        # check now much this changes
59        old = counters[me]
60        change = value - old
61        counters[me] = value
62
63        # add change to the current
64        curr = curr + change
65        single.append( value )
66
67        pass
68
69print(single)
70
71# single = sorted(single)[:len(single)-100]
72# ms = max(single)
73# single = [float(x) / 2500.0 for x in single]
74
75#print
76# for t, v in single:
77#       print([t, v])
78# print(len(single))
79# print(max(single))
80# print(min(single))
81
82# bins = [0, 5.37751600e+04, 1.06903320e+05, 1.60031480e+05, 2.13159640e+05, 2.66287800e+05, 3.19415960e+05, 3.72544120e+05, 4.25672280e+05, 4.78800440e+05, 5.31928600e+05, 5.85056760e+05, 6.38184920e+05, 6.91313080e+05, 7.44441240e+05, 7.97569400e+05, 8.50697560e+05, 9.03825720e+05, 9.56953880e+05, 1.01008204e+06, 1.06321020e+06, 1.11633836e+06, 1.16946652e+06, 1.22259468e+06, 1.27572284e+06, 1.32885100e+06, 1.38197916e+06, 1.43510732e+06, 1.48823548e+06, 1.54136364e+06, 1.59449180e+06, 1.64761996e+06, 1.70074812e+06, 1.75387628e+06, 1.80700444e+06, 1.86013260e+06, 1.91326076e+06, 1.96638892e+06, 2.01951708e+06, 2.07264524e+06, 2.12577340e+06, 2.17890156e+06, 2.23202972e+06, 2.28515788e+06, 2.33828604e+06, 2.39141420e+06, 2.44454236e+06, 2.49767052e+06, 2.55079868e+06, 2.60392684e+06, 3.0e+06]
83# # bins = [float(x) / 2500.0 for x in bins]
84# # print([round(b, 2) for b in bins])
85
86# import numpy
87# # hist1, _ = numpy.histogram(single, density=True, bins=50)
88# hist2, _ = numpy.histogram(single, density=True, bins=bins)
89# # print(hist1)
90# print([1000.0 * h for h in hist2])
91# # for v in single:
92# #     print([v])
Note: See TracBrowser for help on using the repository browser.