calibrate.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import sys
  2. operations = {}
  3. with open("calibration/result", 'r') as f:
  4. for l in f:
  5. op, t = l.split(": ")
  6. t = float(t)
  7. operations.setdefault(op, []).append(t)
  8. with open("calibration/averages", 'w') as averages:
  9. with open("calibration/plot", 'w') as plot:
  10. for op in operations:
  11. avg = sum(operations[op]) / len(operations[op])
  12. op_min = 0.0
  13. op_max = avg * 3
  14. averages.write("%20s: %f\n" % (op, avg))
  15. with open("calibration/distribution_%s" % op, 'w') as f:
  16. for t in sorted(operations[op]):
  17. if t < op_max:
  18. f.write("%f\n" % t)
  19. plot.write("set terminal postscript enhanced colour portrait size 6,6\n")
  20. plot.write("n = 20\n")
  21. plot.write("min=%s\n" % op_min)
  22. plot.write("max=%s\n" % op_max)
  23. plot.write("width=(max-min)/n\n")
  24. plot.write("hist(x, width)=width*floor(x/width)+width/2.0\n")
  25. plot.write("set out 'calibration/plot_%s.eps'\n" % op)
  26. plot.write("set ylabel 'Frequency (time)'\n")
  27. plot.write("set xlabel 'Duration (s)'\n")
  28. plot.write("set title 'Operation %s'\n" % op.replace("_", "\\_"))
  29. plot.write("plot 'calibration/distribution_%s' u (hist($1,width)):(1.0) smooth freq w boxes\n" % op)