Changeset 359d12d
- Timestamp:
- Jun 26, 2020, 2:53:34 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b813f53
- Parents:
- f2b18d01
- Location:
- tools/perf
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/perf/process_halts.sh
rf2b18d01 r359d12d 1 1 #!/bin/bash -e 2 2 3 DIR=$( dirname "${BASH_SOURCE[0]}") 4 echo $DIR 5 tmpfile=$(mktemp) 6 function finish { 7 rm -rf "$tmpfile" 8 } 9 trap finish EXIT 3 SAVE_TEMPS=false 4 while (( "$#" )); do 5 case "$1" in 6 -s|--save-temps) 7 SAVE_TEMPS=true 8 shift 9 ;; 10 *) # preserve positional arguments 11 PARAMS="$PARAMS $1" 12 shift 13 ;; 14 esac 15 done 16 # set positional arguments in their proper place 17 eval set -- "$PARAMS" 10 18 19 if $SAVE_TEMPS; then 20 tmpfile=$(mktemp --tmpdir=$(pwd)) 21 echo "Saving to $tmpfile" 22 else 23 tmpfile=$(mktemp) 24 function finish { 25 rm -rf "$tmpfile" 26 } 27 trap finish EXIT 28 fi 11 29 # split the wanted and unwanted output 12 30 awk "/^Processor|^PH:[0-9]+ - [0-9]+ [0-9]+/ {print \$0 > \"$tmpfile\"; next}{print \$0; fflush()}" 13 31 14 32 # pass the data to the python scirpt 15 $DIR/view_halts.py $tmpfile 33 DIR=$( dirname "${BASH_SOURCE[0]}") 34 cat $tmpfile | $DIR/view_halts.py ${PARAMS} -
tools/perf/view_halts.py
rf2b18d01 r359d12d 3 3 import re 4 4 import sys, getopt 5 import fileinput 5 6 import argparse 6 7 8 #-------------------------------------------------------------------------------- 9 # Parse arguments 10 parser = argparse.ArgumentParser(description='Produce a graph representing CPU activity over time.') 11 parser.add_argument('-i', '--input' , dest='infile' , type=argparse.FileType('r'), default=sys.stdin, help='input file containing processor activity; if none specified then will use stdin.') 12 parser.add_argument('-o', '--output', dest='outfile', type=argparse.FileType('w'), default=None, help='output file with any image format extension such as .png or .svg; if none specified then plt.show() will be used') 13 args = parser.parse_args() 14 15 #-------------------------------------------------------------------------------- 16 # Process data 7 17 class Proc: 8 18 def __init__(self, id, name, address): … … 21 31 #-------------------------------------------------------------------------------- 22 32 # Parse data 23 with 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 33 for line in args.infile: 34 match = re.match("Processor : ([0-9]+) - (.*) \((0x[0-9a-f]+)\)", line) 35 if match : 36 id = int(match.group(1)) 37 processors[id] = Proc(id, match.group(2), match.group(3)) 38 continue 30 39 31 32 33 34 35 36 37 40 match = re.match("PH:([0-9]+) - ([0-9]+) ([0-9]+)", line) 41 if match : 42 id = int(match.group(1)) 43 if not id in data: 44 data[id] = [] 45 data[id].append(Point(int(match.group(2)), int(match.group(3)))) 46 continue 38 47 39 48 print("WARNING : line '%s' filterred not matched" % line, file=sys.stderr) 40 49 41 50 #-------------------------------------------------------------------------------- 42 51 # Check data 52 if not data: 53 print("ERROR : no data extracted from '%s'" % args.infile, file=sys.stderr) 54 43 55 for d in data: 44 56 if not d in processors: … … 61 73 # Convert data to series 62 74 offset = min(data) 63 print(offset) 64 65 series=dict() ## dict of pairs of arrays 75 series = dict() 66 76 for d in data: 67 77 series[d] = ([], [], []) … … 87 97 print('number of series={}'.format(len(series))) 88 98 for s, xy in series.items(): 89 print(' plotting series {} with {} points'.format(s, len(xy[0]))) 99 if s in processors: 100 name = '"{}" ({})'.format(processors[s].name, processors[s].address) 101 else: 102 name = s 103 print( ' plotting series {} with {} points'.format(name, len(xy[0])) ) 90 104 plt.fill_between(xy[0], xy[1], xy[2], step="post", alpha=0.4) 91 105 plt.step(xy[0], xy[1], where='post') … … 107 121 # do the plot 108 122 plt.tight_layout() 109 print("saving figure image %s\n" % "out.svg") 110 plt.savefig("out.svg") 123 if not args.outfile: 124 plt.show() 125 else: 126 print("saving figure image %s\n" % args.outfile.name) 127 plt.savefig(args.outfile.name)
Note: See TracChangeset
for help on using the changeset viewer.