In [1]:
!head -n3 bench.json
In [2]:
import json
graphics = {}
with open("bench.json") as infile:
for line in infile:
r = json.loads(line)
k = (r["type"], r.get("num_threads", 1), r["exponent"])
graphics.setdefault(k, 0.)
graphics[k] += r["sec"]
x_axis = range(8, 29)
y_serial = [graphics[('serial', 1, _)] / 5. for _ in x_axis]
y_parallels = {thrd: [graphics[('parallel', thrd, _)] / 5. for _ in x_axis] for thrd in range(2, 9)}
In [ ]:
import plotly.offline as py
import plotly.graph_objs as go
py.init_notebook_mode()
data = [go.Scatter(x = x_axis,
y = y_serial,
mode = 'lines+markers',
name = 'Serail')]
for k in y_parallels:
data.append(go.Scatter(x = x_axis,
y = y_parallels[k],
mode = 'lines+markers',
name = 'Parallel, {} threads'.format(k)))
layout = dict(title='MergeSort Benchmark', xaxis=dict(title='Power'), yaxis=dict(title="Seconds"))
py.iplot(go.Figure(data=data, layout=layout))