#!/usr/bin/env python # Copyright (c) 2015, NORDUnet A/S. # See LICENSE for licensing information. import argparse import sys import ast import itertools def parse_one_line(line): row = line.rstrip().split(":") assert row[0].startswith("bench-") iteration = int(row[0][6:]) stage = row[2].strip() data = ast.literal_eval(row[3].strip()) return (iteration, stage, data) def main(): parser = argparse.ArgumentParser(description="") parser.add_argument('inputfile', help="Input file", nargs='*') args = parser.parse_args() print "" print "" print "" print "" print "" for filename in args.inputfile: parse_one_file(filename) print "" print "" scale = 0.25 def parse_one_file(filename): lines = [parse_one_line(line) for line in open(filename)] iterations = itertools.groupby(lines, lambda x: x[0]) print "

%s

" % (filename,) print "
" firsttime = True stageorderdict = {} stageorder = [] stages = {} itemorder = {} for (i, iteration) in iterations: for (_, stage, data) in iteration: if stage not in stages: stageorderdict[stage] = len(stageorderdict) stageorder.append(stage) stages[stage] = {} itemorder[stage] = [] for (item, useconds) in data: if item not in stages[stage]: itemorder[stage].append(item) stages[stage][item] = len(stages[stage]) iterations = itertools.groupby(lines, lambda x: x[0]) for (i, iteration) in iterations: print >>sys.stderr, (i, iteration) sys.stdout.write("
") for (_, stage, data) in iteration: data = list(data) for (itemn, (item, useconds)) in enumerate(data): seconds = useconds / 1000000 shades = stages[stage] step = 50 / (len(shades) - 1) shade = shades[item] stagen = stageorderdict[stage] print "
" % (int(seconds*scale), stagen * 90, shade * step + 40, stage, item, seconds) print " " sys.stdout.write("
") sys.stdout.write("
") print "
" print "
" print "
" print "
" for stage in stageorder: print "
%s" % (stage,) shades = stages[stage] for item in itemorder[stage]: shade = shades[item] step = 50 / (len(shades) - 1) stagen = stageorderdict[stage] print "%s" % (stagen * 90, shade * step + 40, item) print "
" print "
" main()