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