import sys operations = {} with open("calibration/result", 'r') as f: for l in f: op, t = l.split(": ") t = float(t) operations.setdefault(op, []).append(t) 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_min = 0.0 op_max = avg * 3 new_list = [] with open("calibration/distribution_%s" % op, 'w') as f: for t in sorted(operations[op]): if t < op_max: f.write("%f\n" % t) new_list.append(t) avg = sum(new_list) / len(new_list) averages.write("%20s: %f\n" % (op, avg)) plot.write("set terminal postscript enhanced colour portrait size 6,6\n") plot.write("n = 20\n") plot.write("min=%s\n" % op_min) plot.write("max=%s\n" % op_max) plot.write("width=(max-min)/n\n") plot.write("hist(x, width)=width*floor(x/width)+width/2.0\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 (hist($1,width)):(1.0) smooth freq w boxes\n" % op)