123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import sys
- operations = {}
- with open(sys.argv[1] if len(sys.argv) > 1 else "calibration/result", 'r') as f:
- for l in f:
- try:
- op, t = l.split(": ")
- t = float(t)
- operations.setdefault(op, []).append(t)
- except:
- pass
- s = 0.0
- with open("calibration/averages", 'w') as averages:
- with open("calibration/plot", 'w') as plot:
- for op in operations:
- avg = sum(operations[op]) / len(operations[op])
- op_max = avg * 3
- new_list = []
- with open("calibration/distribution_%s" % op, 'w') as f:
- for t in operations[op]:
- f.write("%.17f\n" % float(t))
- averages.write("%20s: %.17f\n" % (op, avg))
- plot.write("set terminal postscript enhanced colour portrait size 6,6\n")
- plot.write("set xtics rotate by -45\n")
- plot.write("n = 20\n")
- plot.write("max=%s\n" % op_max)
- plot.write("width=max/n\n")
- plot.write("set boxwidth width absolute\n")
- plot.write("set style fill solid 1.0 noborder\n")
- plot.write("rounded(x)=width*floor(x/width)+width/2\n")
- plot.write("set out 'calibration/plot_%s.eps'\n" % op)
- plot.write("set ylabel 'Frequency (time)'\n")
- plot.write("set xlabel 'Duration (s)'\n")
- plot.write("set title 'Operation %s'\n" % op.replace("_", "\\_"))
- plot.write("plot 'calibration/distribution_%s' u (rounded($1)):(1) smooth freq w boxes title ''\n" % op)
- print("%s: %s x %s = %s" % (op, avg, len(operations[op]), avg * len(operations[op])))
- s += avg * len(operations[op])
- print("TOTAL: " + str(s))
|