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

Added more unctionaltiy to the scaling plots

parent 3c9dbb10
No related branches found
No related tags found
No related merge requests found
import matplotlib
import os
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import pandas as pd import pandas as pd
import numpy as np import numpy as np
...@@ -5,22 +7,17 @@ import numpy as np ...@@ -5,22 +7,17 @@ import numpy as np
def calc_mean_and_std(arr): def calc_mean_and_std(arr):
return np.mean(arr), np.std(arr) return np.mean(arr), np.std(arr)
####
# Configure # Configure
result_file = 'comparison_result.dat' result_file = 'comparison_result.dat'
result_file = 'comparison_result_astro1.dat' result_file = 'comparison_result_astro1.dat'
name_testcase = 'Astro1' name_testcase = 'Astro1'
img_dir = 'scaling_plots'
# Readout file
#
results = [] results = []
with open(result_file, 'r') as f: with open(result_file, 'r') as f:
for line in f: for line in f:
res = list(eval(line.strip())) res = list(eval(line.strip()))
...@@ -71,16 +68,20 @@ for i in unique_amt_cores: ...@@ -71,16 +68,20 @@ for i in unique_amt_cores:
calculated_results.append(res_dict) calculated_results.append(res_dict)
#############################################################################################################################
# Plot # Plot speed up and efficiency.
x_position_shift = 0 x_position_shift = 0
y_position_shift = -0.05 y_position_shift = -0.05
max_speedup = 0 max_speedup = 0
# https://stackoverflow.com/questions/46323530/matplotlib-plot-two-x-axes-one-linear-and-one-with-logarithmic-ticks
fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
for amt_systems in unique_amt_systems: for amt_systems in unique_amt_systems:
cores = [] cores = []
speedup = [] speedup = []
std = [] std = []
efficiency = []
for el in calculated_results: for el in calculated_results:
if el['systems']==amt_systems: if el['systems']==amt_systems:
...@@ -88,29 +89,81 @@ for amt_systems in unique_amt_systems: ...@@ -88,29 +89,81 @@ for amt_systems in unique_amt_systems:
cores.append(el['cores'] + x_position_shift) cores.append(el['cores'] + x_position_shift)
speedup.append(el['mean_ratio']) speedup.append(el['mean_ratio'])
std.append(el['std_ratio']) std.append(el['std_ratio'])
efficiency.append(el['mean_ratio']/el['cores'])
if el['mean_ratio'] > max_speedup: if el['mean_ratio'] > max_speedup:
max_speedup = el['mean_ratio'] max_speedup = el['mean_ratio']
# add number of runs its based on # 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']) ax1.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)) ax1.errorbar(cores, speedup, std, linestyle='None', marker='^', label='Speed up & efficiency of {} systems'.format(amt_systems))
ax2.plot(cores, efficiency, alpha=0.5)
x_position_shift += 0.1 x_position_shift += 0.1
plt.title("Speed up ratio vs amount of cores for different amounts of systems on {}".format(name_testcase)) ax1.set_title("Speed up ratio vs amount of cores for different amounts of systems on {}".format(name_testcase))
plt.xlabel("Amount of cores used") ax1.set_xlabel("Amount of cores used")
plt.ylabel("Speed up ratio (time_linear/time_parallel)") ax1.set_ylabel("Speed up ratio (time_linear/time_parallel)")
ax1.set_xlim(0, max(unique_amt_cores) + 4)
ax1.set_ylim(0, max_speedup + 2)
ax2.set_ylim(0, 1)
ax1.grid()
ax1.legend(loc=4)
fig.savefig(os.path.join(img_dir, 'speedup_scaling_{}.{}'.format(name_testcase, 'png')))
fig.savefig(os.path.join(img_dir, 'speedup_scaling_{}.{}'.format(name_testcase, 'pdf')))
fig.savefig(os.path.join(img_dir, 'speedup_scaling_{}.{}'.format(name_testcase, 'eps')))
plt.show()
#####
# Plot run time
# fig = plt.figure()
# ax = fig.add_subplot(111)
# color_options = ['blue', 'green', 'red', 'black', 'yellow', 'magenta']
# x_position_shift = 0
# y_position_shift = -0.05
# colors = [color_options[i] for i in range(len(unique_amt_systems))]
# for i, amt_systems in enumerate(unique_amt_systems):
# cores = []
# mean_times_linear = []
# mean_times_multiprocessing = []
# std_linear = []
# std_mp = []
# for el in calculated_results:
# if el['systems']==amt_systems:
# cores.append(el['cores'] + x_position_shift)
# mean_times_linear.append(el['mean_time_sequential'])
# std_linear.append(el['std_sequential'])
# mean_times_multiprocessing.append(el['mean_time_multiprocessing'])
# std_mp.append(el['std_multiprocessing'])
# # # 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'])
# ax.errorbar(cores, mean_times_linear, std_linear, color=colors[i], linewidth=1, marker='P', label='{} systems linear run'.format(amt_systems))
# ax.errorbar(cores, mean_times_multiprocessing, std_multiprocessing, linewidth=1, color=colors[i], marker='d', label='{} systems MP run'.format(amt_systems))
# x_position_shift += 0.1
plt.xlim(0, max(unique_amt_cores) + 4) # ax.set_title("Total time for sequential and MP for different amounts of systems on {}".format(name_testcase))
plt.ylim(0, max_speedup + 2) # ax.set_xlabel("Amount of cores used")
# ax.set_ylabel("Total time taken (s)")
plt.grid() # ax.set_xlim(0, max(unique_amt_cores) + 20)
plt.legend() # ax.set_yscale('log')
# ax.grid()
# ax.legend()
plt.savefig('scaling_{}.png'+'.png') # fig.savefig(os.path.join(img_dir, 'total_time_scaling_{}.{}'.format(name_testcase, 'png')))
plt.savefig('scaling_{}.png'+'.pdf') # fig.savefig(os.path.join(img_dir, 'total_time_scaling_{}.{}'.format(name_testcase, 'pdf')))
plt.savefig('scaling_{}.svg'+'.pdf') # fig.savefig(os.path.join(img_dir, 'total_time_scaling_{}.{}'.format(name_testcase, 'eps')))
plt.show() # plt.show()
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
File added
tests/population/scaling_plots/speedup_scaling_Astro1.png

64.3 KiB

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