MergeSort benchmark

1. Вычитываем результат бенчмарка


In [1]:
!head -n3 bench.json


{"type": "serial", "exponent": 8, "repeat": 0, "sec": 9.1e-05}
{"type": "parallel", "exponent": 8, "num_threads": 2, "repeat": 0, "sec": 0.00017}
{"type": "parallel", "exponent": 8, "num_threads": 3, "repeat": 0, "sec": 0.007732}

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)}

2. Строим графики


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))