#!/usr/bin/env python3 import sys sys.stdin.reconfigure(encoding='utf-8',errors='replace') def leftmiddleright(S): n = len(S)//2 if len(S)%2 == 1: middle = S[n] return S[:n]+[middle],middle,[middle]+S[n+1:] return S[:n],(S[n-1]+S[n])/2,S[n:] def quartiles(S): S = sorted(S) S0,q2,S1 = leftmiddleright(S) S00,q1,S01 = leftmiddleright(S0) S10,q3,S11 = leftmiddleright(S1) return q1,q2,q3 def median(S): return quartiles(S)[1] def mean(S): S = list(S) return sum(S)/len(S) def stq(S): S = sorted(8*list(S)) n = len(S)//8 return mean(S[n:3*n]),mean(S[3*n:5*n]),mean(S[5*n:7*n]) data = {} for line in sys.stdin: if line.startswith('+'): continue line = line.split() if len(line) < 10: continue what = line[6] if what != 'cycles' and not what.endswith('_cycles'): continue abi = line[2] o = line[4] p = line[5] size = line[7] key = abi,o,p,size,what measurements = list(map(int,line[9:])) assert int(line[8]) == median(measurements) if key not in data: data[key] = [] data[key] += measurements x = [] y1 = [] y2 = [] y3 = [] c = [] for key in data: S = data[key] q1,q2,q3 = quartiles(S) stq1,stq2,stq3 = stq(S) n = len(S) print('q1/q3',q1/q3,'stq1/stq3',stq1/stq3,'stq1/q1',stq1/q1,'stq2/q2',stq2/q2,'stq3/q3',stq3/q3,'q1',q1,'q2',q2,'q3',q3,'stq1',stq1,'stq2',stq2,'stq3',stq3,'n',n,str(key).replace(' ',''),str(S).replace(' ','')) if stq1 >= 0.75*stq3 and stq1 <= 0.95*stq3: x += [stq1/stq3] y1 += [stq1/q1] y2 += [stq2/q2] y3 += [stq3/q3] color = 'green' if n < 90: color = 'blue' if n < 30: color = 'orange' c += [color] import matplotlib import matplotlib.pyplot as plt from matplotlib.backends.backend_pdf import PdfPages for outputfile,data in ( ('stq1q1-stq1stq3.pdf',y1), ('stq2q2-stq1stq3.pdf',y2), ('stq3q3-stq1stq3.pdf',y3), ): fig,ax = plt.subplots() fig.set_size_inches(5,5) plt.xlim(0.75,0.95) ax.set_axisbelow(True) ax.grid(which='major') plt.scatter(x,data,c=c,s=3,linewidths=0.5,marker='x') fig.tight_layout() with PdfPages(outputfile) as pdf: pdf.savefig() plt.close() sys.stderr.write(f'plotted {len(x)} points\n')