#!/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 "
" legend = [] firsttime = True for (i, iteration) in iterations: print >>sys.stderr, (i, iteration) print "" for (stagen, (_, stage, data)) in enumerate(iteration): if firsttime: legend.append("
%s" % (stage,)) data = list(data) for (itemn, (item, useconds)) in enumerate(data): seconds = useconds / 1000000 step = 50 / (len(data) - 1) print "
" if firsttime: legend.append("") print "
" % (int(seconds*scale), stagen * 90, itemn * step + 40, stage, item, seconds) if firsttime: legend.append("%s" % (stagen * 90, itemn * step + 40, item)) print " " print "
" firsttime = False print "
" print "
" print "
" print "
" for row in legend: print row print "
" main()