Skip to content
Snippets Groups Projects
Commit 0e0709e7 authored by Viken's avatar Viken
Browse files

Update

parent 37357543
Branches
No related tags found
No related merge requests found
...@@ -78,7 +78,6 @@ for metric in metrics_choices: ...@@ -78,7 +78,6 @@ for metric in metrics_choices:
r = [] r = []
for i in range(len(names)): for i in range(len(names)):
r.append(i) r.append(i)
#print(r)
colors=['black', 'red', 'green', 'blue', 'cyan'] colors=['black', 'red', 'green', 'blue', 'cyan']
...@@ -101,6 +100,7 @@ for metric in metrics_choices: ...@@ -101,6 +100,7 @@ for metric in metrics_choices:
plt.show() plt.show()
# Automatic saving # Automatic saving
if Prompt.ask("Do you want to save the plot ?", choices=['y','n'], default='n'):
date = datetime.datetime.now() date = datetime.datetime.now()
plt.savefig('plots/'+metric+'-'+str(date.year)+str(date.month)+str(date.day)+'-'+str(date.hour)+str(date.minute)+'.png') plt.savefig('plots/'+metric+'-'+str(date.year)+str(date.month)+str(date.day)+'-'+str(date.hour)+str(date.minute)+'.png')
......
plots/cost-2023731-103.png

2.34 KiB

plots/cost-2023731-955.png

2.34 KiB

plots/encrypted_file_size-2023731-942.png

2.34 KiB

plots/execution_time-2023731-942.png

2.34 KiB

plots/implementation_size-2023731-942.png

2.34 KiB

plots/memory_usage-2023731-942.png

2.34 KiB

plots/ram_consumption-2023731-942.png

2.34 KiB

plots/throughput-2023731-942.png

2.34 KiB

...@@ -42,6 +42,8 @@ def normalize_data(DATA): ...@@ -42,6 +42,8 @@ def normalize_data(DATA):
#### Cost function #### Cost function
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import datetime
def cost_scenario(scenario, data): def cost_scenario(scenario, data):
""" """
Calculate and visualize the cost of scenarios based on the provided data. Calculate and visualize the cost of scenarios based on the provided data.
...@@ -53,6 +55,7 @@ def cost_scenario(scenario, data): ...@@ -53,6 +55,7 @@ def cost_scenario(scenario, data):
Returns: Returns:
None. None.
""" """
data = normalize_data(data) data = normalize_data(data)
# we prepare the weight # we prepare the weight
WEIGHT = {} WEIGHT = {}
...@@ -86,7 +89,6 @@ def cost_scenario(scenario, data): ...@@ -86,7 +89,6 @@ def cost_scenario(scenario, data):
for i in range(1, len(data_list), 3) : for i in range(1, len(data_list), 3) :
cost = 0 cost = 0
# x_data = [algo,key_length,block_length,operation,integrity,implementation_size,ram_consumption,throughput,execution_time,memory_usage,encrypted_file_size]
encryption_data = data_list[i] encryption_data = data_list[i]
decryption_data = data_list[i+1] decryption_data = data_list[i+1]
cost += WEIGHT["end_user1"]["implementation_size"]*encryption_data[5] cost += WEIGHT["end_user1"]["implementation_size"]*encryption_data[5]
...@@ -101,20 +103,28 @@ def cost_scenario(scenario, data): ...@@ -101,20 +103,28 @@ def cost_scenario(scenario, data):
cost += WEIGHT["end_user2"]["execution_time"]*decryption_data[8] cost += WEIGHT["end_user2"]["execution_time"]*decryption_data[8]
cost += WEIGHT["end_user2"]["encrypted_file_size"]*decryption_data[10] cost += WEIGHT["end_user2"]["encrypted_file_size"]*decryption_data[10]
costs[mode].append(cost) costs[mode].append(cost)
## pas fini, faut tracer mtn,
plt.barh(algo['stream'], costs["stream"]) plt.barh(algo['stream'], costs["stream"])
plt.barh(algo['block'], costs["block"]) plt.barh(algo['block'], costs["block"])
plt.title(f'Cost in the scenario : {scenario}') #plt.title(f'Cost in the scenario : {scenario}')
plt.show() plt.show()
# On explicite les meilleur # On explicite les meilleurs
best_cost = [min(costs["stream"]),min(costs["block"])] best_cost = [min(costs["stream"]),min(costs["block"])]
best_algo_index = [costs["stream"].index(best_cost[0]), costs["block"].index(best_cost[1])] best_algo_index = [costs["stream"].index(best_cost[0]), costs["block"].index(best_cost[1])]
print(f"The best for stream is {algo['stream'][best_algo_index[0]]}") print(f"The best for stream is {algo['stream'][best_algo_index[0]]} with a cost of {best_cost[0]}")
print(f"\nThe best for block is {algo['block'][best_algo_index[1]]}") print(f"\nThe best for block is {algo['block'][best_algo_index[1]]} with a cost of {best_cost[1]}")
# Automatic saving
if Prompt.ask("Do you want to save the plot ?", choices=['y','n'], default='n'):
date = datetime.datetime.now()
plt.savefig('plots/'+'cost'+'-'+str(date.year)+str(date.month)+str(date.day)+'-'+str(date.hour)+str(date.minute)+'.png')
# Clear after saving
plt.clf()
plt.cla()
################################################################################## ##################################################################################
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment