Skip to content
Snippets Groups Projects
Commit 76c2e45e authored by David Hendriks's avatar David Hendriks
Browse files

added routine to show some scaling plots for the grid

parent a0d5be66
No related branches found
No related tags found
No related merge requests found
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
def calc_mean_and_std(arr):
return np.mean(arr), np.std(arr)
# Readout
result_file = 'comparison_result.dat'
results = []
name_testcase = 'laptop David'
with open(result_file, 'r') as f:
for line in f:
res = list(eval(line.strip()))
res.append(res[-2]/res[-1])
results.append(res)
# make dataframe
headers = ['cores', 'total_systems', 'total_time_sequentially', 'total_time_multiprocessing', 'ratio']
df = pd.DataFrame(results)
df.columns = headers
# Select unique amounts
unique_amt_cores = df['cores'].unique()
unique_amt_systems = df['total_systems'].unique()
# Create dictionary with calculated means and stdevs etc
calculated_results = []
for i in unique_amt_cores:
for j in unique_amt_systems:
total_time_sequential_list, total_time_multiprocessing_list, total_ratio_list = [], [], []
for res in results:
if (res[0]==i) & (res[1]==j):
total_time_sequential_list.append(res[2])
total_time_multiprocessing_list.append(res[3])
total_ratio_list.append(res[4])
if (total_time_sequential_list) and (total_time_multiprocessing_list) and (total_ratio_list):
# calculate stuff
mean_time_sequential, std_sequential = calc_mean_and_std(np.array(total_time_sequential_list))
mean_time_multiprocessing, std_multiprocessing = calc_mean_and_std(np.array(total_time_multiprocessing_list))
mean_ratio, std_ratio = calc_mean_and_std(np.array(total_ratio_list))
# make dict
res_dict = {
'cores': i,
'systems': j,
'mean_time_sequential': mean_time_sequential,
'mean_time_multiprocessing':mean_time_multiprocessing,
'mean_ratio': mean_ratio,
'std_sequential': std_sequential,
'std_multiprocessing': std_multiprocessing,
'std_ratio': std_ratio,
'total_runs': len(total_time_sequential_list)
}
calculated_results.append(res_dict)
# Plot
x_position_shift = 0
y_position_shift = -0.05
for amt_systems in unique_amt_systems:
cores = []
speedup = []
std = []
for el in calculated_results:
if el['systems']==amt_systems:
cores.append(el['cores'] + x_position_shift)
speedup.append(el['mean_ratio'])
std.append(el['std_ratio'])
# add number of runs its based on
plt.text(el['cores'] + x_position_shift+0.01, el['mean_ratio']+y_position_shift, el['total_runs'])
plt.errorbar(cores, speedup, std, linestyle='None', marker='^', label='{} systems'.format(amt_systems))
x_position_shift += 0.04
plt.title("Speed up ratio vs amount of cores for different amounts of systems on {}".format(name_testcase))
plt.xlabel("Amount of cores used")
plt.ylabel("Speed up ratio (time_linear/time_parallel)")
plt.legend()
plt.show()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment