11 def filter_name(results, name):
13 return ent[0]['name'] == name
14 return [x for x in results if match(x)]
16 def order_results_by_threads(results):
17 # res is list[(config, results)], change to
18 # list[(num_threads, results)]
20 return (ent[0]['threads'], ent[1])
21 return map(trfm, results)
23 def split_results_by_predicate(results, pred):
32 def extract_result_position(k, res):
34 return [x[k] for x in res]
37 def extract_throughput(results, persist):
39 return (ent[0], extract_result_position(0 if not persist else 1, ent[1]))
40 return map(trfm, results)
42 def extract_latency(results, persist):
44 return (ent[0], extract_result_position(2 if not persist else 3, ent[1]))
45 return map(trfm, results)
48 return [e[0] for e in x]
50 def median(x): return sorted(x)[len(x)/2]
57 return [checked(e[1]) for e in x]
64 return [checked(e[1])/float(e[0]) for e in x]
67 ypts = [e[1] for e in x]
68 ymins = np.array([min(x) for x in ypts])
69 ymaxs = np.array([max(x) for x in ypts])
70 ymid = np.array([median(x) for x in ypts])
71 yerr=np.array([ymid - ymins, ymaxs - ymid])
75 ypts = [[ee/float(e[0]) for ee in e[1]] for e in x]
76 ymins = np.array([min(x) for x in ypts])
77 ymaxs = np.array([max(x) for x in ypts])
78 ymid = np.array([median(x) for x in ypts])
79 yerr=np.array([ymid - ymins, ymaxs - ymid])
82 def handle_scale_tpcc(f, results):
84 # x-axis is num threads on both
85 # y-axis[0] is throughput
86 # y-axis[1] is latency
88 no_persist, with_persist = \
89 split_results_by_predicate(results, lambda x: not x[0]['persist'])
90 no_persist, with_persist = \
91 order_results_by_threads(no_persist), order_results_by_threads(with_persist)
93 no_persist_throughput, no_persist_latency = \
94 extract_throughput(no_persist, False), extract_latency(no_persist, False)
95 with_persist_throughput, with_persist_latency = \
96 extract_throughput(with_persist, True), extract_latency(with_persist, True)
100 ax.errorbar(XX(no_persist_throughput), YY(no_persist_throughput), yerr=YERR(no_persist_throughput))
101 ax.errorbar(XX(with_persist_throughput), YY(with_persist_throughput), yerr=YERR(with_persist_throughput))
102 ax.legend(('No-Persist', 'Persist'), loc='upper left')
103 ax.set_xlabel('threads')
104 ax.set_ylabel('throughput (txns/sec)')
105 bname = '.'.join(os.path.basename(f).split('.')[:-1])
106 fig.savefig('.'.join([bname + '-scale_tpcc-throughput', 'pdf']))
109 ax = plt.subplot(111)
110 ax.errorbar(XX(no_persist_throughput), YYPC(no_persist_throughput), yerr=YERRPC(no_persist_throughput))
111 ax.errorbar(XX(with_persist_throughput), YYPC(with_persist_throughput), yerr=YERRPC(with_persist_throughput))
112 ax.legend(('No-Persist', 'Persist'), loc='upper left')
113 ax.set_xlabel('threads')
114 ax.set_ylabel('throughput (txns/sec/core)')
115 ax.set_ylim([20000, 32000])
116 bname = '.'.join(os.path.basename(f).split('.')[:-1])
117 fig.savefig('.'.join([bname + '-scale_tpcc-per-core-throughput', 'pdf']))
120 ax = plt.subplot(111)
121 ax.errorbar(XX(no_persist_latency), YY(no_persist_latency), yerr=YERR(no_persist_latency))
122 ax.errorbar(XX(with_persist_latency), YY(with_persist_latency), yerr=YERR(with_persist_latency))
123 ax.legend(('No-Persist', 'Persist'), loc='upper left')
124 ax.set_xlabel('threads')
125 ax.set_ylabel('latency (ms/txn)')
126 bname = '.'.join(os.path.basename(f).split('.')[:-1])
127 fig.savefig('.'.join([bname + '-scale_tpcc-latency', 'pdf']))
129 if __name__ == '__main__':
135 scale_tpcc = filter_name(RESULTS, 'scale_tpcc')
137 handle_scale_tpcc(f, scale_tpcc)