source: tools/perf/view_halts.py @ f2b18d01

arm-ehenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since f2b18d01 was f2b18d01, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

First version of tools to view halts

  • Property mode set to 100755
File size: 3.2 KB
Line 
1#!/usr/bin/python3
2import numpy as np
3import re
4import sys, getopt
5import argparse
6
7class Proc:
8        def __init__(self, id, name, address):
9                self.name    = name
10                self.address = address
11                self.id      = id
12
13class Point:
14        def __init__(self, time, on):
15                self.time = time
16                self.on = on
17
18processors = {}
19data = {}
20
21#--------------------------------------------------------------------------------
22# Parse data
23with open(sys.argv[1], "r") as f:
24        for line in f:
25                match = re.match("Processor : ([0-9]+) - (.*) \((0x[0-9a-f]+)\)", line)
26                if match :
27                        id = int(match.group(1))
28                        processors[id] = Proc(id, match.group(2), match.group(3))
29                        continue
30
31                match = re.match("PH:([0-9]+) - ([0-9]+) ([0-9]+)", line)
32                if match :
33                        id = int(match.group(1))
34                        if not id in data:
35                                data[id] = []
36                        data[id].append(Point(int(match.group(2)), int(match.group(3))))
37                        continue
38
39                print("WARNING : line '%s' filterred not matched" % line, file=sys.stderr)
40
41#--------------------------------------------------------------------------------
42# Check data
43for d in data:
44        if not d in processors:
45                print("WARNING : unkown processor '%s'" % d, file=sys.stderr)
46
47        prevT = data[d][0].time
48        prevO = data[d][0].on
49        for p in data[d][1:]:
50                if prevT > p.time:
51                        print("WARNING : Time is inconsistant for Proc '%s'" % d, file=sys.stderr)
52
53                if prevO == p.on:
54                        print("WARNING : State is inconsistant for Proc '%s' at %s-%s" % (d, prevT, p.time), file=sys.stderr)
55
56                prevT = p.time
57                prevO = p.on
58
59
60#--------------------------------------------------------------------------------
61# Convert data to series
62offset = min(data)
63print(offset)
64
65series=dict() ## dict of pairs of arrays
66for d in data:
67        series[d] = ([], [], [])
68        for p in data[d]:
69                series[d][0].append( p.time )
70                series[d][1].append(p.on + d - offset)
71                series[d][2].append(d - offset)
72
73#--------------------------------------------------------------------------------
74# setup matplotlib
75import matplotlib as mpl
76mpl.use('Agg')
77import matplotlib.pyplot as plt
78import matplotlib.ticker as ticker
79plt.style.use('dark_background')
80
81#--------------------------------------------------------------------------------
82# setup plot
83dots_per_inch = 2000
84height_inches = 5
85width_inches = 12
86fig = plt.figure(figsize=(width_inches, height_inches), dpi=dots_per_inch)
87print('number of series={}'.format(len(series)))
88for s, xy in series.items():
89        print('    plotting series {} with {} points'.format(s, len(xy[0])))
90        plt.fill_between(xy[0], xy[1], xy[2], step="post", alpha=0.4)
91        plt.step(xy[0], xy[1], where='post')
92
93#--------------------------------------------------------------------------------
94# y axis major, minor
95ax = plt.gca()
96ax.grid(which='major', axis='y', linestyle='-', color='lightgray')
97ax.yaxis.set_minor_locator(ticker.AutoMinorLocator())
98ax.grid(which='minor', axis='y', linestyle='dotted', color='gray')
99
100#--------------------------------------------------------------------------------
101# x axis major, minor
102ax.grid(which='major', axis='x', linestyle='-', color='lightgray')
103ax.xaxis.set_minor_locator(ticker.AutoMinorLocator())
104ax.grid(which='minor', axis='x', linestyle='dotted', color='gray')
105
106#--------------------------------------------------------------------------------
107# do the plot
108plt.tight_layout()
109print("saving figure image %s\n" % "out.svg")
110plt.savefig("out.svg")
Note: See TracBrowser for help on using the repository browser.