In [1]:
%load_ext autoreload
%autoreload 2
In [2]:
import os, json, glob
import pandas as pd
In [3]:
nb_step = 1e6
dic_table = {}

for path in glob.glob('dump/perf-*/results.json'):
    with open(path, 'r') as f:
        dic = json.loads(f.read())
        lang, machine, nb_core, parallel = dic['name'].split('-')[1:5]
        nb_core = int(nb_core)
        if nb_core == 1: parallel = 'none'
        key = (machine, lang, nb_core, parallel)
        dic_table[key] = {
            'Runtime (s)': dic['runtime'],
            'Best Solution': min([e['dist'] for e in dic['solutions']]),
            'Nb Step/core/sec': nb_step/dic['runtime'],
            'Nb Step/sec': nb_core*nb_step/dic['runtime'],
        }

df = pd.DataFrame(dic_table).T
df.index.names = ['Machine', 'Lang', 'Nb Core', 'Parallel']
df = df.reset_index()
    

df['machine_no'] = df['Machine'].replace({'MBPro': 1, 'iMac': 2, 'LinuxVM': 3})
df['parallel_no'] = df['Parallel'].replace({'none': 0, 'concurrent': 2, 'omp': 3})
df = df.sort_values(['Lang', 'parallel_no', 'Nb Core', 'machine_no'])
df = df.reset_index(drop=True)

df = df[['Machine', 'Lang', 'Nb Core', 'Parallel', 'Runtime (s)', 
         'Best Solution', 'Nb Step/core/sec', 'Nb Step/sec']]

df['Raw Speed'] = df['Nb Step/sec']/df['Nb Step/sec'].iloc[0]

df['Speed Up/machine'] = 1.0
for i in range(1, 5):
    for j in range(3):
        k = i*3+j
        df.loc[k, 'Speed Up/machine'] = df['Raw Speed'].iloc[k]/df['Raw Speed'].iloc[j]

df['Runtime (s)'] = df['Runtime (s)'].map('{:.2f}'.format)
df['Best Solution'] = df['Best Solution'].map('{:.6f}'.format)
df['Nb Step/core/sec'] = df['Nb Step/core/sec'].map('{:,.0f}'.format)
df['Nb Step/sec'] = df['Nb Step/sec'].map('{:,.0f}'.format)
df['Raw Speed'] = df['Raw Speed'].map('{:.1f}'.format)
df['Speed Up/machine'] = df['Speed Up/machine'].map('{:.1f}'.format)


df.to_csv('dump/df_perf.csv')

df
Out[3]:
Machine Lang Nb Core Parallel Runtime (s) Best Solution Nb Step/core/sec Nb Step/sec Raw Speed Speed Up/machine
0 MBPro python 1 none 60.05 8.127789 16,652 16,652 1.0 1.0
1 iMac python 1 none 53.08 8.202204 18,841 18,841 1.1 1.0
2 LinuxVM python 1 none 65.79 8.178604 15,201 15,201 0.9 1.0
3 MBPro python 2 concurrent 65.26 8.038648 15,323 30,645 1.8 1.8
4 iMac python 4 concurrent 60.58 7.965396 16,506 66,024 4.0 3.5
5 LinuxVM python 32 concurrent 67.50 7.936524 14,816 474,102 28.5 31.2
6 MBPro pythran 1 none 3.76 8.108755 265,999 265,999 16.0 16.0
7 iMac pythran 1 none 3.21 8.085336 311,829 311,829 18.7 16.6
8 LinuxVM pythran 1 none 2.07 8.225056 482,777 482,777 29.0 31.8
9 MBPro pythran 2 concurrent 3.73 8.051354 268,002 536,004 32.2 32.2
10 iMac pythran 4 concurrent 3.46 8.080405 289,075 1,156,301 69.4 61.4
11 LinuxVM pythran 32 concurrent 2.30 7.935386 435,655 13,940,949 837.2 917.1
12 MBPro pythran 2 omp 4.03 8.193334 247,888 495,775 29.8 29.8
13 iMac pythran 4 omp 4.02 7.959538 248,557 994,229 59.7 52.8
14 LinuxVM pythran 32 omp 23.29 7.959538 42,946 1,374,270 82.5 90.4
In [ ]: