-rwxr-xr-x 1569 sortbench-20240116/plot raw
#!/usr/bin/env python3 import sys color = {} data = {} args = sys.argv[1:] while len(args) >= 3: label,c,fn,args = *args[:3],args[3:] data[label] = [] color[label] = c with open(fn) as f: for line in f: line = line.strip().split() if len(line) < 4: continue n = int(line[0]) q1 = int(line[1]) q2 = int(line[2]) q3 = int(line[3]) q1 *= 0.25/n q2 *= 0.25/n q3 *= 0.25/n data[label] += [(n,q1,q2,q3)] import matplotlib import matplotlib.pyplot as plt from matplotlib.backends.backend_pdf import PdfPages fig,ax = plt.subplots() fig.set_size_inches((6,6)) plt.title('y = median cycles per byte for sorting int32[x]') plt.semilogx(base=2) plt.semilogy(base=2) ax.xaxis.set_major_locator(matplotlib.ticker.LogLocator(base=2,numticks=22)) ax.yaxis.set_major_locator(matplotlib.ticker.LogLocator(base=2)) ax.yaxis.set_minor_locator(matplotlib.ticker.LogLocator(base=2,subs=(1.414213562373095,))) ax.yaxis.set_minor_formatter('') ax.yaxis.grid(True,which='minor') plt.grid(visible=True) plt.tight_layout() handles = {} todo = [] for label in data: for n,q1,q2,q3 in data[label]: todo += [(q2,q1,q3,n,label)] for q2,q1,q3,n,label in reversed(sorted(todo)): onebar = plt.errorbar([n],[q2],yerr=([q2-q1],[q3-q2]),label=label,marker='o',markersize=2.0,linewidth=1.0,capsize=1.0,markeredgewidth=1.0,color=color[label]) if label not in handles: handles[label] = onebar plt.legend(handles=[handles[label] for label in data]) with PdfPages('plot.pdf') as pdf: pdf.savefig() plt.close()