Beispiel #1
0
if args.file:
    inf = open(args.file, "r")
else:
    inf = sys.stdin

rc = csv.reader(inf)
timestamps = dict()
value = dict()

def isnum(x):
    return re.match(r'[0-9.]+', x)

val = ""
for row in rc:
    r = csv_formats.parse_csv_row(row)
    if r is None:
        continue
    ts, cpu, event, val = r.ts, r.cpu, r.ev, r.val
    if event not in assigned:
        level = gen_level.get_level(event)
        assigned[event] = cur_colors[level][0]
        cur_colors[level] = cur_colors[level][1:]
        if len(cur_colors[level]) == 0:
            cur_colors[level] = all_colors
        value[event] = []
        timestamps[event] = []
    timestamps[event].append(float(ts))
    try:
        value[event].append(float(val.replace("%","")))
    except ValueError:
Beispiel #2
0
    inf = open(args.file, "r")
else:
    inf = sys.stdin

rc = csv.reader(inf)
timestamps = dict()
value = dict()


def isnum(x):
    return re.match(r'[0-9.]+', x)


val = ""
for row in rc:
    r = csv_formats.parse_csv_row(row)
    if r is None:
        continue
    ts, cpu, event, val = r.ts, r.cpu, r.ev, r.val
    if event not in assigned:
        level = gen_level.get_level(event)
        assigned[event] = cur_colors[level][0]
        cur_colors[level] = cur_colors[level][1:]
        if len(cur_colors[level]) == 0:
            cur_colors[level] = all_colors
        value[event] = []
        timestamps[event] = []
    timestamps[event].append(float(ts))
    try:
        value[event].append(float(val.replace("%", "")))
    except ValueError:
events = collections.OrderedDict()
out = []
times = []
cpus = []
rc = csv.reader(args.inputfile)
res = []
writer = csv.writer(args.output, lineterminator='\n')
lastcpu = None
cpu = None
lineno = 1
for row in rc:
    if len(row) > 0 and (row[0] == "Timestamp" or row[0].startswith("#")):
        lineno += 1
        continue
    r = csv_formats.parse_csv_row(row, error_exit=args.error_exit)
    if r is None:
        print("at line %d" % lineno, file=sys.stderr)
        lineno += 1
        continue
    ts, cpu, ev, val = r.ts, r.cpu, r.ev, r.val

    if ts != timestamp or (cpu != lastcpu and not args.normalize_cpu):
        if timestamp:
            if args.cpu and cpu != args.cpu:
                continue
            # delay in case we didn't see all headers
            # only need to do that for toplev, directly output for perf?
            # could limit buffering to save memory?
            out.append(res)
            times.append(timestamp)