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]:
<matplotlib.legend.Legend at 0x7f27c6489fd0>

overhead en fonction proba


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]:
[<matplotlib.lines.Line2D at 0x7f27c795c358>]

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]:
<matplotlib.legend.Legend at 0x7f27c821a940>

half steal vs steal 80% (proba)


In [ ]:

overhead en fonction max steal


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]:
<matplotlib.legend.Legend at 0x7f4aa57cf208>

half steal vs steal 80% (static)


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]:
<matplotlib.legend.Legend at 0x7f4aa3523f28>

In [84]:
x


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-84-6fcf9dfbd479> in <module>
----> 1 x

NameError: name 'x' is not defined

In [ ]: