Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
SiNa88 authored Feb 7, 2023
1 parent 6261cec commit be98847
Show file tree
Hide file tree
Showing 81 changed files with 13,535 additions and 0 deletions.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

988 changes: 988 additions & 0 deletions Real-world-evaluations/00Light/1/Pros/diff_times.py

Large diffs are not rendered by default.

75 changes: 75 additions & 0 deletions Real-world-evaluations/00Light/1/Pros/diff_times_ecommerce.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import numpy
import json


def comp_times_ecommerce(task,dev_new, dev1, dev2, dev3, num_of_src):
#print(dev_new, " ",dev1, " ",dev2, " ", dev3)
LAT1=0; BW1=0; LAT2=0; BW2=0; LAT3=0; BW3=0
alloc_file = "D:\\00Research\\00Fog\\004-Zara\\Her SLA\\TimeIntervals-large - diffStress\\00Light\\1\\Pros\\networkDefinition2.json"
with open(alloc_file, "r") as json_file:
network = json.load(json_file)
for i in range(len((network["link"]))):
if ((network["link"][i]["s"] == dev1 and network["link"][i]["d"] == dev_new ) or (network["link"][i]["s"] == dev_new and network["link"][i]["d"] == dev1 )):
#print(dev1," ",dev_new)
LAT1 = network["link"][i]["PR"]
BW1 = network["link"][i]["BW"]
if ((network["link"][i]["s"] == dev2 and network["link"][i]["d"] == dev_new ) or (network["link"][i]["s"] == dev_new and network["link"][i]["d"] == dev2 )) :
LAT2 = network["link"][i]["PR"]
BW2 = network["link"][i]["BW"]
if ((network["link"][i]["s"] == dev3 and network["link"][i]["d"] == dev_new ) or (network["link"][i]["s"] == dev_new and network["link"][i]["d"] == dev3 )):
LAT3 = network["link"][i]["PR"]
BW3 = network["link"][i]["BW"]
if (dev1 == dev_new ):
LAT1 = 0.5e-3
BW1 = 13000
if (dev2 == dev_new ):
LAT2 = 0.5e-3
BW2 = 13000
if (dev3 == dev_new ):
LAT3 = 0.5e-3
BW3 = 13000
#####################################SockShop####################################

# 0 1 2 3 4 5 6 7 8 10 11 12
# Exo(lg) Exo(med) Exo(smal) Exo(lg) Exo(lg) Exo(Klag) EGS Lenovo Jetson RPi4 Exo(lg) Exo(lg)
'''time =[ [0.27, 0.4, 0.44, 0.27, 0.27, 0.28, 0.17, 0.33, 1.9, 2.16, 0.27, 0.27], # encode 200
[0.41, 0.42, 0.44, 0.41, 0.41, 0.5, 0.39, 0.35, 2, 3.8, 0.41, 0.41], # frame 200
[0.25, 0.26, 0.29, 0.25, 0.25, 0.28, 0.225, 0.282, 1.94, 1.05, 0.25, 0.25], # inference
[0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001], #Low-acc. training
[0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001] #High-acc. training
]'''
time = [[0.048611, 0.049296, 0.094595, 0.048611, 0.048611, 0.029167, 0.006034, 0.016129, 0.085784, 0.068627, 0.012153],
[0.048611, 0.049296, 0.094595, 0.048611, 0.048611, 0.029167, 0.006034, 0.016129, 0.085784, 0.068627, 0.012153],
[0.048611, 0.049296, 0.094595, 0.048611, 0.048611, 0.029167, 0.006034, 0.016129, 0.085784, 0.068627, 0.012153],
[0.055556, 0.056338, 0.108108, 0.055556, 0.055556, 0.033333, 0.006897, 0.018433, 0.098039, 0.078431, 0.013889],
[0.048611, 0.049296, 0.094595, 0.048611, 0.048611, 0.029167, 0.006034, 0.016129, 0.085784, 0.068627, 0.012153],
[0.048611, 0.049296, 0.094595, 0.048611, 0.048611, 0.029167, 0.006034, 0.016129, 0.085784, 0.068627, 0.012153],
[0.048611, 0.049296, 0.094595, 0.048611, 0.048611, 0.029167, 0.006034, 0.016129, 0.085784, 0.068627, 0.012153],
[0.048611, 0.049296, 0.094595, 0.048611, 0.048611, 0.029167, 0.006034, 0.016129, 0.085784, 0.068627, 0.012153]]

index_of_segment = 3
data_size = [6.22*1024*8, 8.48*1024*8, 11.25*1024*8, 22.48*1024*8] # bits
SIZE = 1

# Converting string to list
tasks0 = ["Web-UI", "Login", "Orders", "Shopping-cart", "Catalogue", "Accounts", "Payment", "Shipping"] # sys.argv[1].strip("][").split(",")
#print((tasks0.index(task)))

T = [1 for i in range(len(time[0]))]
Tm = [1 for i in range(len(time[0]))]
Tr = [1 for i in range(len(time[0]))]
Tq = [1 for i in range(len(time[0]))]

#print(dev_new, " ", int(dev_new/10))

Tm[int(dev_new/10)] = time[tasks0.index(task)][int(dev_new/10)] # data size: 8sec video.
#print(Tm[int(dev_new/10)])
Tr[int(dev_new/10)] = max(((0.000001) * (SIZE*data_size[index_of_segment]) / BW1) + ((0.000001) *LAT1),
((0.000001) * (SIZE*data_size[index_of_segment]) / BW2) + ((0.000001) *LAT2),
((0.000001) * (SIZE*data_size[index_of_segment]) / BW3) + ((0.000001) *LAT3))

Tq[int(dev_new/10)] = num_of_src*Tr[int(dev_new/10)]
T[int(dev_new/10)] = numpy.round(numpy.round(Tm[int(dev_new/10)], 4) + Tq[int(dev_new/10)] + numpy.round(Tr[int(dev_new/10)], 4), 4)

return (Tm, Tr, Tq, T)
#comp_times_ecommerce(0,0,0,0,0)
150 changes: 150 additions & 0 deletions Real-world-evaluations/00Light/1/Pros/extract_alloc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import numpy
import json
import sys
sys.path.append('./diff_times')
from diff_times import comp_times
sys.path.append('./diff_times_ecommerce')
from diff_times_ecommerce import comp_times_ecommerce

import warnings
warnings.filterwarnings("ignore", category=numpy.VisibleDeprecationWarning)


num_of_src = 10
res_num=12
app_num=30
for tt in range(1):
alloc_file = "D:\\00Research\\00Fog\\004-Zara\\Her SLA\\TimeIntervals-large - diffStress\\00Light\\1\\Pros\\allocDefinition_NF1.json"
with open(alloc_file, "r") as json_file:
content_app = json.load(json_file)
#print(len(content_app['initialAllocation']))
app1 = ["Web-UI", "Login", "Orders", "Shopping-cart", "Catalogue", "Accounts", "Payment", "Shipping"]
service_num_app1=8
T_1 = [[[[0] for k in range(res_num)] for i in range(service_num_app1)] for j in range(app_num)]
Tm_1 = [[[[0] for k in range(res_num)] for i in range(service_num_app1)] for j in range(app_num)]
Tq_1 = [[[[0] for k in range(res_num)] for i in range(service_num_app1)] for j in range(app_num)]
Tr_1 = [[[[0] for k in range(res_num)] for i in range(service_num_app1)] for j in range(app_num)]
dev_1 = [[[0] for i in range(service_num_app1)] for j in range(app_num)]
compl_time = [0 for k in range(app_num)]

app2 = ["encode_20000", "frame_20000", "lowtrain", "hightrain", "inference", "transcode", "package"]
service_num_app2=7
T_2 = [[[[0] for k in range(res_num)] for i in range(service_num_app2)] for j in range(app_num)]
Tm_2 = [[[[0] for k in range(res_num)] for i in range(service_num_app2)] for j in range(app_num)]
Tq_2 = [[[[0] for k in range(res_num)] for i in range(service_num_app2)] for j in range(app_num)]
Tr_2 = [[[[0] for k in range(res_num)] for i in range(service_num_app2)] for j in range(app_num)]
dev_2 = [[[0] for i in range(service_num_app2)] for j in range(app_num)]
#compl_time_2 = 0
#print(len(content_app['initialAllocation']))
for service in range(len(content_app['initialAllocation'])):
if (service < 120):
#print(service)
m=content_app['initialAllocation'][service]["module_name"]
part1 = int(m.split('_')[1])
task =(part1) % service_num_app1
#print(content_app['initialAllocation'][service])
#print(app1[task])
###print(task)

app = int(content_app['initialAllocation'][service]["app"])
dev_1[app][task] = content_app['initialAllocation'][service]["id_resource"]
if dev_1[app][task]==1000:
dev_1[app][task]=10
#print(dev_1[app][task])
if (task == 0):
Tm_1[app][task], Tr_1[app][task], Tq_1[app][task], T_1[app][task] = comp_times_ecommerce(app1[task],dev_1[app][task], 7, 7, 7, num_of_src)
if (content_app['initialAllocation'][service]["Status"] == "Crashed"):
T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]= T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] + T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]
compl_time[app] += T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] #+ max(T_1[app][task][int(numpy.floor(dev_1[app][task]/10))],T_1[app][task][int(numpy.floor(dev_1[app][task]/10))],T_1[app][task][int(numpy.floor(dev_1[app][task]/10))],T_1[app][task][int(numpy.floor(dev_1[app][task]/10))])
elif(task == 1):
Tm_1[app][task], Tr_1[app][task], Tq_1[app][task], T_1[app][task] = comp_times_ecommerce(app1[task],dev_1[app][task], dev_1[app][task-1], dev_1[app][task-1], dev_1[app][task-1], num_of_src)
if (content_app['initialAllocation'][service]["Status"] == "Crashed"):
T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]= T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] + T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]
compl_time[app] += T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] + max(T_1[app][task-1][int(numpy.floor(dev_1[app][task-1]/10))],T_1[app][task-1][int(numpy.floor(dev_1[app][task-1]/10))],T_1[app][task-1][int(numpy.floor(dev_1[app][task-1]/10))])
elif(task == 2):
Tm_1[app][task], Tr_1[app][task], Tq_1[app][task], T_1[app][task] = comp_times_ecommerce(app1[task],dev_1[app][task], dev_1[app][task-2], dev_1[app][task-2], dev_1[app][task-2], num_of_src)
if (content_app['initialAllocation'][service]["Status"] == "Crashed"):
T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]= T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] + T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]
compl_time[app] += T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] + max(T_1[app][task-2][int(numpy.floor(dev_1[app][task-2]/10))],T_1[app][task-2][int(numpy.floor(dev_1[app][task-2]/10))],T_1[app][task-2][int(numpy.floor(dev_1[app][task-2]/10))])
elif(task == 3):
Tm_1[app][task], Tr_1[app][task], Tq_1[app][task], T_1[app][task] = comp_times_ecommerce(app1[task],dev_1[app][task], dev_1[app][task-1], dev_1[app][task-3], dev_1[app][task-3], num_of_src)
if (content_app['initialAllocation'][service]["Status"] == "Crashed"):
T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]= T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] + T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]
compl_time[app] += T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] + max(T_1[app][task-1][int(numpy.floor(dev_1[app][task-1]/10))],T_1[app][task-3][int(numpy.floor(dev_1[app][task-3]/10))],T_1[app][task-3][int(numpy.floor(dev_1[app][task-3]/10))])
elif(task == 4):
Tm_1[app][task], Tr_1[app][task], Tq_1[app][task], T_1[app][task] = comp_times_ecommerce(app1[task],dev_1[app][task], dev_1[app][task-4], dev_1[app][task-4], dev_1[app][task-4], num_of_src)
if (content_app['initialAllocation'][service]["Status"] == "Crashed"):
T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]= T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] + T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]
compl_time[app] += T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] + max(T_1[app][task-4][int(numpy.floor(dev_1[app][task-4]/10))],T_1[app][task-4][int(numpy.floor(dev_1[app][task-4]/10))],T_1[app][task-4][int(numpy.floor(dev_1[app][task-4]/10))])
elif(task == 5):
Tm_1[app][task], Tr_1[app][task], Tq_1[app][task], T_1[app][task] = comp_times_ecommerce(app1[task],dev_1[app][task], dev_1[app][task-3], dev_1[app][task-4], dev_1[app][task-5], num_of_src)
if (content_app['initialAllocation'][service]["Status"] == "Crashed"):
T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]= T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] + T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]
compl_time[app] += T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] + max(T_1[app][task-3][int(numpy.floor(dev_1[app][task-3]/10))],T_1[app][task-4][int(numpy.floor(dev_1[app][task-4]/10))],T_1[app][task-5][int(numpy.floor(dev_1[app][task-5]/10))])
elif(task == 6):
Tm_1[app][task], Tr_1[app][task], Tq_1[app][task], T_1[app][task] = comp_times_ecommerce(app1[task],dev_1[app][task], dev_1[app][task-4], dev_1[app][task-4], dev_1[app][task-4], num_of_src)
if (content_app['initialAllocation'][service]["Status"] == "Crashed"):
T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]= T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] + T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]
compl_time[app] += T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] + max(T_1[app][task-4][int(numpy.floor(dev_1[app][task-4]/10))],T_1[app][task-4][int(numpy.floor(dev_1[app][task-4]/10))],T_1[app][task-4][int(numpy.floor(dev_1[app][task-4]/10))])
elif(task == 7):
Tm_1[app][task], Tr_1[app][task], Tq_1[app][task], T_1[app][task] = comp_times_ecommerce(app1[task],dev_1[app][task], dev_1[app][task-5], dev_1[app][task-5], dev_1[app][task-5], num_of_src)
if (content_app['initialAllocation'][service]["Status"] == "Crashed"):
T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]= T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] + T_1[app][task][int(numpy.floor(dev_1[app][task]/10))]
compl_time[app] += T_1[app][task][int(numpy.floor(dev_1[app][task]/10))] + max(T_1[app][task-5][int(numpy.floor(dev_1[app][task-5]/10))],T_1[app][task-5][int(numpy.floor(dev_1[app][task-5]/10))],T_1[app][task-5][int(numpy.floor(dev_1[app][task-5]/10))])
#print(app," ",compl_time[app])
#dev_1[app][task] = content_app['initialAllocation'][service]["id_resource"]
#if dev_1[app][task]==1000:
# #dev_1[app][task]=10
# print(app," ",task," ",10," ",T_1[app][task][10])
#else:
############print(app," ",task," ",dev_1[app][task]," ",T_1[app][task][int(numpy.floor(dev_1[app][task]/10))])
else:
m=content_app['initialAllocation'][service]["module_name"]
part1 = int(m.split('_')[1])
task =( part1 - 120) % service_num_app2
#print(content_app['initialAllocation'][service])
#print(app2[task])
#print(t1)

app = int(content_app['initialAllocation'][service]["app"])
#print(app)
if (task == 0):
Tm_2[app][task], Tr_2[app][task], Tq_1[app][task], T_2[app][task] = comp_times(app2[task], 7, 7, 7, num_of_src)
if (content_app['initialAllocation'][service]["Status"] == "Crashed"):
T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))]= T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))] + T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))]
compl_time[app] += T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))]
#print(task, " ",app," ",Tm_2[app][task][int(numpy.floor(dev_1[app][task]/10))]," ", Tr_2[app][task][int(numpy.floor(dev_1[app][task]/10))], " ",T_2[app][task][int(numpy.floor(dev_1[app][task]/10))])
elif(task == 4):
Tm_2[app][task], Tr_2[app][task], Tq_1[app][task], T_2[app][task] = comp_times(app2[task], dev_2[app][task-1], dev_2[app][task-2], dev_2[app][task-2], num_of_src)
if (content_app['initialAllocation'][service]["Status"] == "Crashed"):
T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))]= T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))] + T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))]
compl_time[app] += T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))] + max(T_2[app][task-1][int(numpy.floor(dev_1[app][task-1][0]/10))],T_2[app][task-2][int(numpy.floor(dev_1[app][task-2][0]/10))],T_2[app][task-2][int(numpy.floor(dev_1[app][task-2][0]/10))])
#print(task, " ",app," ",Tm_2[app][task][int(numpy.floor(dev_1[app][task]/10))]," ", Tr_2[app][task][int(numpy.floor(dev_1[app][task]/10))], " ",T_2[app][task][int(numpy.floor(dev_1[app][task]/10))])
elif(task == 5):
#print(task, " ",app)
Tm_2[app][task], Tr_2[app][task], Tq_1[app][task], T_2[app][task] = comp_times(app2[task], dev_2[app][task-1], dev_2[app][task-2], dev_2[app][task-3], num_of_src)
if (content_app['initialAllocation'][service]["Status"] == "Crashed"):
T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))]= T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))] + T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))]
compl_time[app] += T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))] + max(T_2[app][task-1][int(numpy.floor(dev_1[app][task-1][0]/10))],T_2[app][task-2][int(numpy.floor(dev_1[app][task-2][0]/10))],T_2[app][task-3][int(numpy.floor(dev_1[app][task-3][0]/10))])
#print(task, " ",app," ", Tm_2[app][task][int(numpy.floor(dev_1[app][task]/10))]," ", Tr_2[app][task][int(numpy.floor(dev_1[app][task]/10))], " ",T_2[app][task][int(numpy.floor(dev_1[app][task]/10))])
else:
Tm_2[app][task], Tr_2[app][task], Tq_1[app][task], T_2[app][task] = comp_times(app2[task], dev_2[app][task-1], dev_2[app][task-1], dev_2[app][task-1], num_of_src)
if (content_app['initialAllocation'][service]["Status"] == "Crashed"):
T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))]= T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))] + T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))]
compl_time[app] += T_2[app][task][int(numpy.floor(dev_1[app][task][0]/10))] + max(T_2[app][task-1][int(numpy.floor(dev_1[app][task-1][0]/10))],T_2[app][task-1][int(numpy.floor(dev_1[app][task-1][0]/10))],T_2[app][task-1][int(numpy.floor(dev_1[app][task-1][0]/10))])
#print(task, " ",app, " ", Tm_2[app][task][int(numpy.floor(dev_1[app][task]/10))]," ", Tr_2[app][task][int(numpy.floor(dev_1[app][task]/10))], " ",T_2[app][task][int(numpy.floor(dev_1[app][task]/10))])
#if(task == 6):
# print(app," ",compl_time[app])
dev_2[app][task] = content_app['initialAllocation'][service]["id_resource"]
'''if dev_2[app][task]==1000:
dev_2[app][task]=10
print(app," ",task," ",10," ",T_2[app][task][10])
#else:
print(app," ",task," ",dev_2[app][task]," ",T_2[app][task][int(numpy.floor(dev_1[app][task]/10))])'''

#{"module_name": "0_0", "app": "0", "id_resource": 6},
print(numpy.round(compl_time[0],4),",",numpy.round(compl_time[1],4),",",numpy.round(compl_time[2],4),",",numpy.round(compl_time[3],4),",",numpy.round(compl_time[4],4),",",numpy.round(compl_time[5],4),",",numpy.round(compl_time[6],4),",",numpy.round(compl_time[7],4),",",numpy.round(compl_time[8],4),",",numpy.round(compl_time[9],4),",")
print(numpy.round(compl_time[10],4),",",numpy.round(compl_time[11],4),",",numpy.round(compl_time[12],4),",",numpy.round(compl_time[13],4),",",numpy.round(compl_time[14],4),",",numpy.round(compl_time[15],4),",",numpy.round(compl_time[16],4),",",numpy.round(compl_time[17],4),",",numpy.round(compl_time[18],4),",",numpy.round(compl_time[19],4),",")
print(numpy.round(compl_time[20],4),",",numpy.round(compl_time[21],4),",",numpy.round(compl_time[22],4),",",numpy.round(compl_time[23],4),",",numpy.round(compl_time[24],4),",",numpy.round(compl_time[25],4),",",numpy.round(compl_time[26],4),",",numpy.round(compl_time[27],4),",",numpy.round(compl_time[28],4),",",numpy.round(compl_time[29],4))

print(numpy.round(numpy.average(compl_time),4))

Large diffs are not rendered by default.

Loading

0 comments on commit be98847

Please sign in to comment.