1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- 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(": ")
- if "LOG" in op:
- continue
- t = float(t)
- operations.setdefault(op, []).append(t)
- except:
- pass
- fancy = {"read_root": "read root ID",
- "read_dict": "read dictionary",
- "read_dict_keys": "read dictionary keys",
- "read_value": "read node value",
- "read_dict_node": "read dictionary by node",
- "rule_generation": "rule generation",
- "read_dict_edge": "read dictionary edge",
- "create_node": "create node",
- "create_edge": "create edge",
- "create_nodevalue": "create value",
- "create_dict": "create dictionary",
- "delete_edge": "delete edge",
- "delete_node": "delete node",
- "purge": "garbage collect",
- "read_reverse_dict": "dictionary key lookup",
- "read_outgoing": "read outgoing edges",
- "read_incoming": "read incoming edges",
- "read_edge": "read edge",
- "read_dict_node_edge": "read dictionary edge by node",
- }
- 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])))
- print("% -23s&% -23s& %.8f\\\\" % (fancy[op], "{:,}".format(len(operations[op])), avg))
- s += avg * len(operations[op])
- #print("TOTAL: " + str(s))
|