def warmup_plot_bintree(): ids_by_val = [ 156 # binary-trees-by-val, 2020-09-01 01:57:02, trufflephp-native , 160 # binary-trees-by-val, 2020-09-01 07:20:34, trufflephp-native , 164 # binary-trees-by-val, 2020-09-01 12:48:38, trufflephp-native ] runs = [get_timings_by_id(i, warmup=0) for i in ids_by_val] do_warmup_plot('binary-trees \ncopy-by-val', runs, num_iter=num_iter, file_prefix=name) ids_by_ref = [ 169 # binary-trees-by-ref, 2020-09-01 14:40:30, trufflephp-native , 171 # binary-trees-by-ref, 2020-09-01 14:48:10, trufflephp-native , 173 # binary-trees-by-ref, 2020-09-01 14:55:38, trufflephp-native , 175 # binary-trees-by-ref, 2020-09-01 15:03:06, trufflephp-native , 177 # binary-trees-by-ref, 2020-09-01 15:10:40, trufflephp-native , 179 # binary-trees-by-ref, 2020-09-01 15:18:15, trufflephp-native , 181 # binary-trees-by-ref, 2020-09-01 15:25:48, trufflephp-native , 183 # binary-trees-by-ref, 2020-09-01 15:33:23, trufflephp-native , 185 # binary-trees-by-ref, 2020-09-01 15:40:56, trufflephp-native ] runs = [get_timings_by_id(i, warmup=0) for i in ids_by_ref] do_warmup_plot('binary-trees \ncopy-by-ref', runs, num_iter=num_iter, color=color_copy_by_ref, file_prefix=name) pass
def warmup_plot_spectralnorm(): ids_by_val = [ 118 # spectralnorm-by-val, 2020-08-31 00:31:52, trufflephp-native , 122 # spectralnorm-by-val, 2020-08-31 00:37:51, trufflephp-native , 126 # spectralnorm-by-val, 2020-08-31 00:43:51, trufflephp-native , 130 # spectralnorm-by-val, 2020-08-31 00:49:50, trufflephp-native , 134 # spectralnorm-by-val, 2020-08-31 00:55:49, trufflephp-native , 138 # spectralnorm-by-val, 2020-08-31 01:01:48, trufflephp-native , 142 # spectralnorm-by-val, 2020-08-31 01:07:47, trufflephp-native , 146 # spectralnorm-by-val, 2020-08-31 01:13:47, trufflephp-native , 150 # spectralnorm-by-val, 2020-08-31 01:19:46, trufflephp-native ] runs = [get_timings_by_id(i, warmup=0) for i in ids_by_val] do_warmup_plot('spectralnorm \ncopy-by-val', runs, num_iter=num_iter, file_prefix=name) ids_by_ref = [ 120 # spectralnorm-by-ref 2020-08-31 00:34:57, trufflephp-native , 124 # spectralnorm-by-ref 2020-08-31 00:40:56, trufflephp-native , 128 # spectralnorm-by-ref 2020-08-31 00:46:55, trufflephp-native , 132 # spectralnorm-by-ref 2020-08-31 00:52:54, trufflephp-native , 136 # spectralnorm-by-ref 2020-08-31 00:58:54, trufflephp-native , 140 # spectralnorm-by-ref 2020-08-31 01:04:53, trufflephp-native , 144 # spectralnorm-by-ref 2020-08-31 01:10:52, trufflephp-native , 148 # spectralnorm-by-ref 2020-08-31 01:16:51, trufflephp-native , 152 # spectralnorm-by-ref 2020-08-31 01:22:50, trufflephp-native ] runs = [get_timings_by_id(i, warmup=0) for i in ids_by_ref] do_warmup_plot('spectralnorm \ncopy-by-ref', runs, num_iter=num_iter, color=color_copy_by_ref, file_prefix=name) pass
def warmup_plot_spectralnorm(): ids_by_val = [ 117 # spectralnorm-by-val, 2020-08-31 00:31, trufflephp , 121 # spectralnorm-by-val, 2020-08-31 00:37, trufflephp , 125 # spectralnorm-by-val, 2020-08-31 00:43, trufflephp , 129 # spectralnorm-by-val, 2020-08-31 00:49, trufflephp , 133 # spectralnorm-by-val, 2020-08-31 00:55, trufflephp , 137 # spectralnorm-by-val, 2020-08-31 01:01, trufflephp , 141 # spectralnorm-by-val, 2020-08-31 01:07, trufflephp , 145 # spectralnorm-by-val, 2020-08-31 01:13, trufflephp , 149 # spectralnorm-by-val, 2020-08-31 01:19, trufflephp ] runs = [get_timings_by_id(i, warmup=0) for i in ids_by_val] do_warmup_plot('spectralnorm \ncopy-by-val', runs, num_iter=num_iter, file_prefix='trufflephp-') ids_by_ref = [ 119 # spectralnorm-by-ref, 2020-08-31 00:34, trufflephp , 123 # spectralnorm-by-ref, 2020-08-31 00:40, trufflephp , 127 # spectralnorm-by-ref, 2020-08-31 00:46, trufflephp , 131 # spectralnorm-by-ref, 2020-08-31 00:52, trufflephp , 135 # spectralnorm-by-ref, 2020-08-31 00:58, trufflephp , 139 # spectralnorm-by-ref, 2020-08-31 01:04, trufflephp , 143 # spectralnorm-by-ref, 2020-08-31 01:10, trufflephp , 147 # spectralnorm-by-ref, 2020-08-31 01:16, trufflephp , 151 # spectralnorm-by-ref, 2020-08-31 01:22, trufflephp ] runs = [get_timings_by_id(i, warmup=0) for i in ids_by_ref] do_warmup_plot('spectralnorm \ncopy-by-ref', runs, num_iter=num_iter, color=color_copy_by_ref, file_prefix='trufflephp-') pass
def warmup_plot_fannkuch(): ids = [ 99 # 2020-08-30, trufflephp , fannkuchredux-1 , 101 # 2020-08-30, trufflephp, fannkuchredux-1 , 103 # 2020-08-30, trufflephp, fannkuchredux-1 , 105 # 2020-08-30, trufflephp, fannkuchredux-1 , 107 # 2020-08-30, trufflephp, fannkuchredux-1 , 109 # 2020-08-30, trufflephp, fannkuchredux-1 , 111 # 2020-08-30, trufflephp, fannkuchredux-1 , 113 # 2020-08-31, trufflephp, fannkuchredux-1 , 115 # 2020-08-31, trufflephp, fannkuchredux-1 ] runs = [get_timings_by_id(i, warmup=0) for i in ids] do_warmup_plot('fannkuchredux \ncopy-by-val', runs, num_iter=num_iter, subtitle='', file_prefix='trufflephp-') pass
def warmup_plot_fannkuch(): ids = [ 100 # fannkuchredux-1, 2020-08-30 21:14, graalphp-native , 102 # fannkuchredux-1, 2020-08-30 21:39, graalphp-native , 104 # fannkuchredux-1, 2020-08-30 22:03, graalphp-native , 106 # fannkuchredux-1, 2020-08-30 22:28, graalphp-native , 108 # fannkuchredux-1, 2020-08-30 22:52, graalphp-native , 110 # fannkuchredux-1, 2020-08-30 23:16, graalphp-native , 112 # fannkuchredux-1, 2020-08-30 23:40, graalphp-native , 114 # fannkuchredux-1, 2020-08-31 00:04, graalphp-native , 116 # fannkuchredux-1, 2020-08-31 00:28, graalphp-native ] runs = [get_timings_by_id(i, warmup=0) for i in ids] do_warmup_plot('fannkuchredux \ncopy-by-val', runs, num_iter=num_iter, subtitle='', file_prefix=name) pass
def warmup_plot_bintree(): ids_by_val = [ 155 # binary-trees-by-val, 2020-09-01 01:57:02, trufflephp , 159 # binary-trees-by-val, 2020-09-01 07:20:34, trufflephp , 163 # binary-trees-by-val, 2020-09-01 12:48:38, trufflephp ] runs = [get_timings_by_id(i, warmup=0) for i in ids_by_val] do_warmup_plot('binary-trees \ncopy-by-val', runs, num_iter=num_iter, file_prefix='trufflephp-') ids_by_ref = [ 168 # binary-trees-by-ref, 2020-09-01 14:40:30, trufflephp , 170 # binary-trees-by-ref, 2020-09-01 14:48:10, trufflephp , 172 # binary-trees-by-ref, 2020-09-01 14:55:38, trufflephp , 174 # binary-trees-by-ref, 2020-09-01 15:03:06, trufflephp , 176 # binary-trees-by-ref, 2020-09-01 15:10:40, trufflephp , 178 # binary-trees-by-ref, 2020-09-01 15:18:15, trufflephp , 180 # binary-trees-by-ref, 2020-09-01 15:25:48, trufflephp , 182 # binary-trees-by-ref, 2020-09-01 15:33:23, trufflephp , 184 # binary-trees-by-ref, 2020-09-01 15:40:56, trufflephp ] runs = [get_timings_by_id(i, warmup=0) for i in ids_by_ref] do_warmup_plot('binary-trees \ncopy-by-ref', runs, num_iter=num_iter, color=color_copy_by_ref, file_prefix='trufflephp-') pass
def fannkuchredux(): ids = [ # by val fannkuch_ids_php_by_val # php 7 , fannkuch_ids_php8_by_val # php 8 , fannkuch_ids_jphp_by_val # jphp , fannkuch_ids_hhvm # hhvm , fannkuch_ids_graalphp_native_by_val # gphp native , fannkuch_ids_graalphp_by_val # gphp ] vals = [] for ids_bench in ids: val_ids = [] for i in ids_bench: val_ids += get_timings_by_id(i, warmup=5) vals.append(val_ids) impl_txt = ( # by val 'PHP 7 \n(baseline)', 'PHP 8 Alpha', 'JPHP', 'HHVM', '\\textbf{graalphp-native}', '\\textbf{graalphp}', ) print(export_to_csv_nested(ids, write_file=False)) avg_baseline = statistics.mean(vals[0]) avgs = [statistics.mean(v) for v in vals] def do_variance(vals, baseline): return statistics.variance([v / baseline for v in vals]) def do_speedup(val, baseline): return baseline / val speedups = [do_speedup(v, avg_baseline) for v in avgs] variance = [do_variance(v, avg_baseline) for v in vals] plt.rcParams.update({ "text.usetex": True, "font.family": "serif", "font.serif": ["Palatino"], }) title = 'Fannkuchredux' xlabel = 'Speedup (larger is better)' impl_indices = np.arange(len(impl_txt)) print(speedups) print(variance) color_by_val = 'blue' fig, ax = plt.subplots(figsize=(6, 3)) ax.barh(impl_indices, speedups, xerr=variance, align='center', alpha=.9 , color=color_by_val) plt.yticks(impl_indices, impl_txt) plt.xlabel(xlabel) plt.title(title) sns.despine() for i, v in enumerate(speedups): ax.text(v + .2, i, '{:.2f}'.format(v), va='center', color='gray') patch_by_val = mpatches.Patch(color=color_by_val, label='copy-by-value (default)') plt.legend(handles=[patch_by_val], loc='lower right') plt.draw() plt.tight_layout() date = str(datetime.datetime.now()).replace(':', '-').replace(' ', '-') plt.savefig("fannkuchredux-" + date + '.svg') plt.show()
def binary_trees_report_plot(): ids = [ # by val bintree_ids_php_by_val # php 7 , bintree_ids_php8_by_val # php 8 , bintree_ids_jphp_by_val # jphp , bintree_ids_hhvm # hhvm , bintree_ids_graalphp_native_by_val # gphp native , bintree_ids_graalphp_by_val # gphp # by ref , bintree_ids_php_by_ref , bintree_ids_php8_by_ref , bintree_ids_jphp_by_ref , bintree_ids_graalphp_native_by_ref , bintree_ids_graalphp_by_ref ] vals = [] for ids_bench in ids: val_ids = [] for i in ids_bench: val_ids += get_timings_by_id(i, warmup=5) vals.append(val_ids) impl_txt = ( # by val 'PHP 7 \n(baseline)', 'PHP 8 Alpha', 'JPHP', 'HHVM', '\\textbf{graalphp-native}', '\\textbf{graalphp}', # by ref 'PHP 7', 'PHP 8 Alpha', 'JPHP', '\\textbf{graalphp-native}', '\\textbf{graalphp}' ) vals_php = vals[0] avg_baseline = statistics.mean(vals_php) avgs = [statistics.mean(v) for v in vals] def do_variance(vals, baseline): return statistics.variance([v / baseline for v in vals]) def do_speedup(val, baseline): return baseline / val speedups = [do_speedup(v, avg_baseline) for v in avgs] variance = [do_variance(v, avg_baseline) for v in vals] plt.rcParams.update({ "text.usetex": True, "font.family": "serif", "font.serif": ["Palatino"], }) plt.rcParams.update({ "text.usetex": True, "font.family": "serif", }) title = 'Binary-Trees' xlabel = 'Speedup (larger is better)' ylabel = 'Implementation' impl_indices = np.arange(len(impl_txt)) print(impl_indices) print(speedups) print(variance) color_by_val = 'blue' color_by_ref = 'green' fig, ax = plt.subplots() ax.barh(impl_indices, speedups, # xerr=variance, align='center', alpha=.9 , color=color_by_val) plt.yticks(impl_indices, impl_txt) plt.xlabel(xlabel) plt.title(title) sns.despine() ax.get_children()[10].set_color(color_by_ref) ax.get_children()[9].set_color(color_by_ref) ax.get_children()[8].set_color(color_by_ref) ax.get_children()[7].set_color(color_by_ref) ax.get_children()[6].set_color(color_by_ref) for i, v in enumerate(speedups): ax.text(v + .2, i, '{:.2f}'.format(v), va='center', color='gray') patch_by_val = mpatches.Patch(color=color_by_val, label='copy-by-value (default)') patch_by_ref = mpatches.Patch(color=color_by_ref, label='copy-by-reference (explicit)') plt.legend(handles=[patch_by_ref, patch_by_val], loc='lower right') plt.draw() plt.tight_layout() date = str(datetime.datetime.now()).replace(':', '-').replace(' ', '-') plt.savefig("binary-trees-" + date + '.svg') plt.show()