In [2]:
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
from collections import defaultdict
from math import log2
In [3]:
def load_file(filename):
a = np.loadtxt(filename, dtype='str', comments='#')
rsp = a[:,0]
latencies = a[:,1]
times = a[:,2]
processors = a[:,3]
work = a[:,4]
i_steals = a[:,16]
e_steals = a[:,17]
return rsp, latencies, times, processors, work
directory = "/home/khatiri/these/projet/ws-simulator/Simulation/simulation/simulation/"
In [4]:
def compute_average(values, latence):
average = defaultdict(int)
run_number = defaultdict(int)
for i in range(len(rsp)):
if int(latencies[i]) == latence:
run_number[float(rsp[i])] += 1
average[float(rsp[i])] += int(values[i])
for cle in average:
average[cle] /= run_number[cle]
return average
def compute_overhead_for_latence(data, latence):
rsp, latencies, times, processors, work = data
average = defaultdict(int)
run_number = defaultdict(int)
for i in range(len(rsp)):
if int(latencies[i]) == latence:
run_number[float(rsp[i])] += 1
average[float(rsp[i])] += float(int(times[i]) - int(work[i])/int(processors[i]))
for cle in average:
average[cle] /= run_number[cle]
return average, min(average.keys(), key=lambda x : average[x])
def compute_overhead(data, latence, variable):
rsp, latencies, times, processors, work = data
average = defaultdict(int)
run_number = defaultdict(int)
average = 0
run_number = 0
for i in range(len(rsp)):
if float(rsp[i]) == variable and float(latencies[i]) == latence:
run_number += 1
average += float(int(times[i]) - int(work[i])/int(processors[i]))
return average/run_number
In [5]:
def plot_for_best(filename):
best = dict()
data = load_file(filename)
latencies = data[1]
for latence in sorted(set(latencies), key=lambda x: int(x)):
avg_overhead, minimum = compute_overhead_for_latence(data, int(latence))
best_avg_overhead = compute_overhead(data, int(latence), minimum)
best[latence] = best_avg_overhead
return best
In [84]:
def latence_for_best_param(filename):
data = load_file(filename)
latencies = data[1]
best = dict()
for latence in sorted(set(latencies), key=lambda x: int(x)):
overhead, minimum = compute_overhead_for_latence(data, int(latence))
#plt.subplot(221)
#plt.plot(overhead1.keys(), overhead.values(), label=filename)
best[latence] = minimum
return best
In [85]:
fig = plt.figure()
fig.set_size_inches(16.5, 8.5, forward=True)
plt.subplot(221)
best = latence_for_best_param(directory + "vss_proba_32_500000000")
plt.plot(best.keys(), best.values(), "o-", label="32_500000000")
best = latence_for_best_param(directory + "vss_proba_32_100000000")
plt.plot(best.keys(), best.values(), "x-", label="32_100000000")
best = latence_for_best_param(directory + "vss_proba_32_50000000")
plt.plot(best.keys(), best.values(), "x-", label="32_50000000")
best = latence_for_best_param(directory + "vss_proba_32_10000000")
plt.plot(best.keys(), best.values(), "x-", label="32_10000000")
plt.legend()
plt.subplot(222)
best = latence_for_best_param(directory + "vss_proba_16_500000000")
plt.plot(best.keys(), best.values(), "o-", label="16_500000000")
best = latence_for_best_param(directory + "vss_proba_16_100000000")
plt.plot(best.keys(), best.values(), "x-", label="16_100000000")
best = latence_for_best_param(directory + "vss_proba_16_50000000")
plt.plot(best.keys(), best.values(), "x-", label="16_50000000")
best = latence_for_best_param(directory + "vss_proba_16_10000000")
plt.plot(best.keys(), best.values(), "x-", label="16_10000000")
plt.legend()
Out[85]:
In [69]:
fig = plt.figure()
fig.set_size_inches(16.5, 8.5, forward=True)
plt.subplot(221)
best = latence_for_best_param(directory + "vss_proba_32_500000000")
plt.plot(best.keys(), best.values(), "o-", label="32_500000000")
best = latence_for_best_param(directory + "vss_proba_32_100000000")
plt.plot(best.keys(), best.values(), "x-", label="32_100000000")
best = latence_for_best_param(directory + "vss_proba_32_50000000")
plt.plot(best.keys(), best.values(), "x-", label="32_50000000")
best = latence_for_best_param(directory + "vss_proba_32_10000000")
plt.plot(best.keys(), best.values(), "x-", label="32_10000000")
plt.legend()
plt.subplot(222)
best = latence_for_best_param(directory + "vss_proba_16_500000000")
plt.plot(best.keys(), best.values(), "o-", label="16_500000000")
best = latence_for_best_param(directory + "vss_proba_16_100000000")
plt.plot(best.keys(), best.values(), "x-", label="16_100000000")
best = latence_for_best_param(directory + "vss_proba_16_50000000")
plt.plot(best.keys(), best.values(), "x-", label="16_50000000")
best = latence_for_best_param(directory + "vss_proba_16_10000000")
plt.plot(best.keys(), best.values(), "x-", label="16_10000000")
plt.legend()
Out[69]:
In [43]:
fig = plt.figure()
fig.set_size_inches(16.5, 8.5, forward=True)
#filename = "/home/khatiri/these/projet/ws-simulator/Simulation/vss_proba_32_100000000"
filename = directory + "vss_proba_32_100000000"
best_proba_50 = plot_for_best(filename)
plt.plot(best_proba_50.keys(), best_proba_50.values(), 'o-', label="proba 50%")
filename = directory + "vss_proba_32_100000000_0.8"
best_proba_80 = plot_for_best(filename)
plt.plot(best_proba_80.keys(), best_proba_80.values(), 'o--', label="proba 80%")
plt.legend()
Out[43]:
In [ ]:
In [94]:
fig = plt.figure()
fig.set_size_inches(16.5, 8.5, forward=True)
filename = directory + "vss_static_32_500000000"
best_static_50 = plot_for_best(filename)
plt.plot(best_static_50.keys(), best_static_50.values(), 'x-', label="static 50%")
filename = directory + "vss_static_32_500000000_0.8"
best_static_80 = plot_for_best(filename)
plt.plot(best_static_80.keys(), best_static_80.values(), 'x--', label="static 80%")
plt.legend()
Out[94]:
In [80]:
ratio_static = dict()
ratio_proba = dict()
for latence in best_static:
ratio_static[latence] = best_static_50[latence]/best_static_80[latence]
ratio_proba[latence] = best_proba_50[latence]/best_proba_80[latence]
plt.plot(ratio_static.keys(), ratio_static.values(), 'bx--', label="static")
plt.plot(ratio_proba.keys(), ratio_proba.values(), 'ro--', label="proba")
plt.legend()
Out[80]:
In [84]:
x
In [ ]: