Changeset d00ce99 for tools/perf
- Timestamp:
- Sep 23, 2021, 11:56:00 AM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- ec421636
- Parents:
- 1cc7689
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/perf/process_stat_array.py
r1cc7689 rd00ce99 1 1 #!/usr/bin/python3 2 2 3 import argparse, os, sys, re 3 import argparse, json, math, os, sys, re 4 from PIL import Image 5 import numpy as np 4 6 5 7 def dir_path(string): … … 11 13 parser = argparse.ArgumentParser() 12 14 parser.add_argument('--path', type=dir_path, default=".cfadata", help= 'paste path to biog.txt file') 15 parser.add_argument('--out', type=argparse.FileType('w'), default=sys.stdout) 13 16 14 17 try : … … 23 26 counters = {} 24 27 28 max_cpu = 0 29 min_cpu = 1000000 30 max_tsc = 0 31 min_tsc = 18446744073709551615 32 25 33 #open the files 26 34 for filename in filenames: … … 31 39 with open(os.path.join(root, filename), 'r') as file: 32 40 for line in file: 33 # data = [int(x.strip()) for x in line.split(',')] 34 data = [int(line.strip())] 35 data = [me, *data] 41 raw = [int(x.strip()) for x in line.split(',')] 42 43 ## from/to 44 high = (raw[1] >> 32) 45 low = (raw[1] & 0xffffffff) 46 data = [me, raw[0], high, low] 47 max_cpu = max(max_cpu, high, low) 48 min_cpu = min(min_cpu, high, low) 49 50 ## number 51 # high = (raw[1] >> 8) 52 # low = (raw[1] & 0xff) 53 # data = [me, raw[0], high, low] 54 # max_cpu = max(max_cpu, low) 55 # min_cpu = min(min_cpu, low) 56 57 58 max_tsc = max(max_tsc, raw[0]) 59 min_tsc = min(min_tsc, raw[0]) 36 60 merged.append(data) 37 61 38 except: 62 except Exception as e: 63 print(e) 39 64 pass 40 65 66 67 print({"max-cpu": max_cpu, "min-cpu": min_cpu, "max-tsc": max_tsc, "min-tsc": min_tsc}) 41 68 42 69 # Sort by timestamp (the second element) … … 47 74 merged.sort(key=takeSecond) 48 75 49 # for m in merged: 50 # print(m) 76 json.dump({"values":merged, "max-cpu": max_cpu, "min-cpu": min_cpu, "max-tsc": max_tsc, "min-tsc": min_tsc}, args.out) 51 77 52 single = [] 53 curr = 0 78 # vmin = merged[ 0][1] 79 # vmax = float(merged[-1][1] - vmin) / 2500000000.0 80 # # print(vmax) 54 81 55 # merge the data 56 # for (me, time, value) in merged: 57 for (me, value) in merged: 58 # check now much this changes 59 old = counters[me] 60 change = value - old 61 counters[me] = value 82 # bins = [] 83 # for _ in range(0, int(math.ceil(vmax * 10))): 84 # bins.append([0] * (32 * 32)) 62 85 63 # add change to the current 64 curr = curr + change 65 single.append( value ) 86 # # print(len(bins)) 87 # bins = np.array(bins) 66 88 67 pass 89 # rejected = 0 90 # highest = 0 68 91 69 print(single) 92 # for x in merged: 93 # b = int(float(x[1] - vmin) / 250000000.0) 94 # from_ = x[2] 95 # if from_ < 0 or from_ > 32: 96 # rejected += 1 97 # continue; 98 # to_ = x[3] 99 # if to_ < 0 or to_ > 32: 100 # rejected += 1 101 # continue; 102 # idx = (to_ * 32) + from_ 103 # bins[b][idx] = bins[b][idx] + 1 104 # highest = max(highest, bins[b][idx]) 105 106 # bins = np.array(map(lambda x: np.int8(x * 255.0 / float(highest)), bins)) 107 108 # print([highest, rejected]) 109 # print(bins.shape) 110 111 # im = Image.fromarray(bins) 112 # im.save('test.png') 113 114 # vmax = merged[-1][1] 115 116 # diff = float(vmax - vmin) / 2500000000.0 117 # print([vmin, vmax]) 118 # print([vmax - vmin, diff]) 119 120 # print(len(merged)) 121 122 # for b in bins: 123 # print(b) 124 125 # single = [] 126 # curr = 0 127 128 # # merge the data 129 # # for (me, time, value) in merged: 130 # for (me, value) in merged: 131 # # check now much this changes 132 # old = counters[me] 133 # change = value - old 134 # counters[me] = value 135 136 # # add change to the current 137 # curr = curr + change 138 # single.append( value ) 139 140 # pass 141 142 # print(single) 70 143 71 144 # single = sorted(single)[:len(single)-100]
Note: See TracChangeset
for help on using the changeset viewer.