| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
import sys, json |
| 25 |
|
| 26 |
lines = [ line.strip() for line in sys.stdin if line.strip() ] |
| 27 |
|
| 28 |
by_benchtype = {} |
| 29 |
benches = {} |
| 30 |
programs = {} |
| 31 |
|
| 32 |
for line in lines: |
| 33 |
benchtype, type, nkeys, program, value = line.split(',') |
| 34 |
nkeys = int(nkeys) |
| 35 |
programs[program] = 1 |
| 36 |
|
| 37 |
if (type == 'time'): |
| 38 |
by_benchtype.setdefault("%s-runtime" % benchtype, {}).setdefault(program, []).append([nkeys, float(value)]) |
| 39 |
else: |
| 40 |
by_benchtype.setdefault("%s-memory" % benchtype, {}).setdefault(program, []).append([nkeys, int(value)]) |
| 41 |
benches[benchtype] = 1 |
| 42 |
|
| 43 |
proper_names = { |
| 44 |
'std::unordered_map': 'std::unordered_map (1 thread)', |
| 45 |
'spp::sparse_hash_map': 'sparsepp (1 thread, use_spp_alloc)', |
| 46 |
'absl::flat_hash_map': 'absl::flat_hash_map (1 thread)', |
| 47 |
'phmap::flat_hash_map': 'phmap::flat_hash_map', |
| 48 |
'phmap::parallel_flat_hash_map': 'phmap::parallel_flat_hash_map (1 thread)', |
| 49 |
'phmap::parallel_flat_hash_map_mt': 'phmap::parallel_flat_hash_map (8 thread)', |
| 50 |
'absl::parallel_flat_hash_map': 'absl::parallel_flat_hash_map (1 thread)', |
| 51 |
'absl::parallel_flat_hash_map_mt': 'absl::parallel_flat_hash_map (8 threads)', |
| 52 |
'phmap::parallel_flat_hash_map_4': 'phmap::parallel_flat_hash_map (N=4, 8 threads)', |
| 53 |
'phmap::parallel_flat_hash_map_5': 'phmap::parallel_flat_hash_map (N=5, 8 threads)', |
| 54 |
'phmap::parallel_flat_hash_map_6': 'phmap::parallel_flat_hash_map (N=6, 8 threads)' |
| 55 |
} |
| 56 |
|
| 57 |
proper_color = { |
| 58 |
'std::unordered_map': 0, |
| 59 |
'spp::sparse_hash_map': 0, |
| 60 |
'absl::flat_hash_map': 1, |
| 61 |
'phmap::flat_hash_map': 1, |
| 62 |
'phmap::parallel_flat_hash_map': 2, |
| 63 |
'phmap::parallel_flat_hash_map_mt': 2, |
| 64 |
'absl::parallel_flat_hash_map': 3, |
| 65 |
'absl::parallel_flat_hash_map_mt': 3, |
| 66 |
'phmap::parallel_flat_hash_map_4': 3, |
| 67 |
'phmap::parallel_flat_hash_map_5': 4, |
| 68 |
'phmap::parallel_flat_hash_map_6': 5 |
| 69 |
} |
| 70 |
|
| 71 |
bench_titles = { |
| 72 |
'lookup': 'Random Lookup', |
| 73 |
'sequential' : 'Sequential Insert', |
| 74 |
'random' : 'Random Insert', |
| 75 |
'delete' : 'Deletion', |
| 76 |
'sequentialstring' : 'Sequential String Insert', |
| 77 |
'randomstring' : 'Random String Insert', |
| 78 |
'deletestring' : 'String Deletion' |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
program_slugs = [ |
| 84 |
'std::unordered_map', |
| 85 |
'sparsepp', |
| 86 |
'absl::flat_hash_map', |
| 87 |
'phmap::flat_hash_map', |
| 88 |
'absl::parallel_flat_hash_map', |
| 89 |
'phmap::parallel_flat_hash_map', |
| 90 |
'phmap::parallel_flat_hash_map_mt', |
| 91 |
'absl::parallel_flat_hash_map_mt', |
| 92 |
'phmap::parallel_flat_hash_map_4', |
| 93 |
'phmap::parallel_flat_hash_map_5', |
| 94 |
'phmap::parallel_flat_hash_map_6' |
| 95 |
] |
| 96 |
|
| 97 |
chart_data = {} |
| 98 |
|
| 99 |
for i, (benchtype, programs) in enumerate(by_benchtype.items()): |
| 100 |
chart_data[benchtype] = [] |
| 101 |
k = programs.keys() |
| 102 |
k.sort() |
| 103 |
for program in k: |
| 104 |
data = programs.get(program, []) |
| 105 |
chart_data[benchtype].append({ |
| 106 |
'label': proper_names[program], |
| 107 |
'color': proper_color[program], |
| 108 |
'data': [], |
| 109 |
}) |
| 110 |
|
| 111 |
for k, (nkeys, value) in enumerate(data): |
| 112 |
chart_data[benchtype][-1]['data'].append([nkeys, value]) |
| 113 |
|
| 114 |
html_chart_data = 'chart_data = ' + json.dumps(chart_data) |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
html_plot_spec = '' |
| 119 |
for b in benches.keys(): |
| 120 |
html_plot_spec += """ |
| 121 |
$.plot($("#{0}-runtime"), chart_data['{0}-runtime'], runtime_settings); |
| 122 |
$.plot($("#{0}-memory"), chart_data['{0}-memory'], memory_settings);""".format(b) |
| 123 |
|
| 124 |
html_div_spec = '' |
| 125 |
first = 1 |
| 126 |
|
| 127 |
for b in benches.keys(): |
| 128 |
if 1: |
| 129 |
first = 0 |
| 130 |
html_div_spec += """ |
| 131 |
<div class="table-title">{1} (integers): Memory Usage</div> |
| 132 |
<div class="chart" id="{0}-memory"></div> |
| 133 |
<div class="xaxis-title">number of entries in hash table</div> |
| 134 |
""".format(b, bench_titles[b]) |
| 135 |
|
| 136 |
html_div_spec += """ |
| 137 |
<div class="table-title">{1} (integers): Execution Time </div> |
| 138 |
<div class="chart" id="{0}-runtime"></div> |
| 139 |
<div class="xaxis-title">number of entries in hash table</div> |
| 140 |
|
| 141 |
""".format(b, bench_titles[b]) |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
html_template = file('charts-template.html', 'r').read() |
| 146 |
|
| 147 |
html_template = html_template.replace('__CHART_DATA_GOES_HERE__', html_chart_data) |
| 148 |
html_template = html_template.replace('__PLOT_SPEC_GOES_HERE__', html_plot_spec) |
| 149 |
html_template = html_template.replace('__PLOT_DIV_SPEC_GOES_HERE__', html_div_spec) |
| 150 |
|
| 151 |
file('charts.html', 'w').write(html_template) |