2023-05-13 11:25:09 +02:00
|
|
|
#!/bin/python3
|
|
|
|
|
|
|
|
import matplotlib.pyplot as plt
|
2024-02-15 23:48:30 +05:30
|
|
|
import numpy as np
|
2023-05-13 11:25:09 +02:00
|
|
|
import os
|
|
|
|
|
|
|
|
def plotData(conf):
|
|
|
|
plt.clf()
|
2023-05-15 17:56:30 +02:00
|
|
|
fig = plt.figure("9, 3")
|
2024-01-21 01:27:17 +05:30
|
|
|
plt.grid(True)
|
2023-05-13 11:25:09 +02:00
|
|
|
if conf["desLoc"] == 1:
|
|
|
|
xDes = 0
|
|
|
|
else:
|
|
|
|
xDes = conf["xdots"][-1] * 0.6
|
|
|
|
props = dict(boxstyle='round', facecolor='wheat', alpha=0.5)
|
2024-01-23 01:46:18 +05:30
|
|
|
plt.text(xDes, conf["yaxismax"]/3, conf["textBox"], fontsize=10, verticalalignment='top', bbox=props)
|
2024-02-18 22:16:16 +05:30
|
|
|
if conf["type"] == "plot" or conf["type"] == "plot_with_1line":
|
2024-01-21 01:27:17 +05:30
|
|
|
for i in range(len(conf["data"])):
|
2023-05-15 17:56:30 +02:00
|
|
|
plt.plot(conf["xdots"], conf["data"][i], conf["colors"][i], label=conf["labels"][i])
|
2024-02-18 22:16:16 +05:30
|
|
|
elif conf["type"] == "individual_bar" or conf["type"] == "individual_bar_with_2line":
|
2024-01-21 01:27:17 +05:30
|
|
|
plt.bar(conf["xdots"], conf["data"])
|
|
|
|
elif conf["type"] == "grouped_bar":
|
|
|
|
for i in range(len(conf["data"])):
|
2023-05-15 17:56:30 +02:00
|
|
|
plt.bar(conf["xdots"], conf["data"][i], label=conf["labels"][i])
|
2024-02-18 22:16:16 +05:30
|
|
|
if conf["type"] == "individual_bar_with_2line":
|
2024-02-18 22:51:19 +05:30
|
|
|
plt.axhline(y = conf["expected_value1"], color='r', linestyle='--', label=conf["line_label1"])
|
|
|
|
plt.axhline(y = conf["expected_value2"], color='g', linestyle='--', label=conf["line_label2"])
|
2024-02-18 22:16:16 +05:30
|
|
|
if conf["type"] == "plot_with_1line":
|
2024-02-18 22:51:19 +05:30
|
|
|
plt.axhline(y = conf["expected_value"], color='g', linestyle='--', label=conf["line_label"])
|
2023-05-13 11:25:09 +02:00
|
|
|
plt.title(conf["title"])
|
|
|
|
plt.ylabel(conf["ylabel"])
|
|
|
|
plt.xlabel(conf["xlabel"])
|
2023-05-15 17:56:30 +02:00
|
|
|
plt.ylim(0, conf["yaxismax"]*1.1)
|
2023-05-13 11:25:09 +02:00
|
|
|
plt.legend(loc=conf["legLoc"])
|
|
|
|
plt.savefig(conf["path"], bbox_inches="tight")
|
|
|
|
|
|
|
|
|
|
|
|
class Visualizor:
|
|
|
|
"""This class helps the visualization of the results"""
|
|
|
|
|
|
|
|
def __init__(self, execID, config, results):
|
|
|
|
"""Initialize the visualizer module"""
|
|
|
|
self.execID = execID
|
|
|
|
self.config = config
|
|
|
|
self.results = results
|
|
|
|
os.makedirs("results/"+self.execID+"/plots", exist_ok=True)
|
|
|
|
|
2023-06-11 19:26:44 +02:00
|
|
|
def plotHeatmaps(self, x, y):
|
|
|
|
"""Plot the heatmap using the parameters given as x axis and y axis"""
|
|
|
|
print("Plotting heatmap "+x+" vs "+y)
|
|
|
|
#Find the location of x in shape
|
|
|
|
#Find the location of y in shape
|
|
|
|
#Find the location od r in shape
|
|
|
|
|
|
|
|
#Loop over all results
|
|
|
|
#Add unique values foir every parameter
|
|
|
|
|
|
|
|
#Find number of runs from r
|
|
|
|
#If number of values for x and y > 3 then plot heatmap, otherwise finish
|
|
|
|
|
|
|
|
#Create a 2D grid with the dimensions of the number of values for x and y
|
|
|
|
#For all values of x
|
|
|
|
#For all values of y
|
|
|
|
# For all values in r
|
|
|
|
#Fixing all other values to 1 (in the mean time)
|
|
|
|
#Add/sum TTA into 2D grid
|
|
|
|
#if last r divide by number of runs
|
|
|
|
|
|
|
|
#Plot 2D grid
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-05-13 11:25:09 +02:00
|
|
|
def plotAll(self):
|
|
|
|
"""Plot all the important elements of each result"""
|
|
|
|
for result in self.results:
|
2023-06-11 18:46:55 +02:00
|
|
|
plotPath = "results/"+self.execID+"/plots/"+str(result.shape)
|
|
|
|
os.makedirs(plotPath, exist_ok=True)
|
2024-01-29 19:50:01 +05:30
|
|
|
self.plotRestoreRowCount(result, plotPath)
|
|
|
|
self.plotRestoreColumnCount(result, plotPath)
|
2024-01-21 01:27:17 +05:30
|
|
|
self.plotMessagesSent(result, plotPath)
|
|
|
|
self.plotMessagesRecv(result, plotPath)
|
|
|
|
self.plotSampleRecv(result, plotPath)
|
2023-06-11 18:46:55 +02:00
|
|
|
self.plotMissingSamples(result, plotPath)
|
|
|
|
self.plotProgress(result, plotPath)
|
|
|
|
self.plotSentData(result, plotPath)
|
|
|
|
self.plotRecvData(result, plotPath)
|
|
|
|
self.plotDupData(result, plotPath)
|
2023-07-15 12:20:13 +00:00
|
|
|
if self.config.saveRCdist:
|
|
|
|
self.plotRowCol(result, plotPath)
|
2023-05-13 11:25:09 +02:00
|
|
|
|
2024-01-29 19:50:01 +05:30
|
|
|
def plotRestoreRowCount(self, result, plotPath):
|
|
|
|
"""Plots the restoreRowCount for each node"""
|
|
|
|
conf = {}
|
|
|
|
text = str(result.shape).split("-")
|
2024-02-18 22:16:16 +05:30
|
|
|
conf["textBox"] = "Row Size: "+text[2]+"\nColumn Size: "+text[6]+"\nNumber of nodes: "+text[10]\
|
2024-02-15 23:48:30 +05:30
|
|
|
+"\nFailure rate: "+text[14]+"%"+"\nNetwork degree: "+text[32]+"\nMalicious Nodes: "+text[36]+"%"
|
2024-01-29 19:50:01 +05:30
|
|
|
conf["title"] = "Restore Row Count for Each Node"
|
|
|
|
conf["type"] = "individual_bar"
|
|
|
|
conf["legLoc"] = 1
|
|
|
|
conf["desLoc"] = 1
|
|
|
|
conf["xlabel"] = "Nodes"
|
|
|
|
conf["ylabel"] = "Restore Row Count"
|
|
|
|
conf["data"] = result.restoreRowCount
|
|
|
|
conf["xdots"] = range(result.shape.numberNodes)
|
|
|
|
conf["path"] = plotPath + "/restoreRowCount.png"
|
|
|
|
maxi = max(conf["data"])
|
|
|
|
conf["yaxismax"] = maxi
|
|
|
|
plotData(conf)
|
|
|
|
print("Plot %s created." % conf["path"])
|
|
|
|
|
|
|
|
def plotRestoreColumnCount(self, result, plotPath):
|
|
|
|
"""Plots the restoreColumnCount for each node"""
|
|
|
|
conf = {}
|
|
|
|
text = str(result.shape).split("-")
|
2024-02-18 22:16:16 +05:30
|
|
|
conf["textBox"] = "Row Size: "+text[2]+"\nColumn Size: "+text[6]+"\nNumber of nodes: "+text[10]\
|
2024-02-15 23:48:30 +05:30
|
|
|
+"\nFailure rate: "+text[14]+"%"+"\nNetwork degree: "+text[32]+"\nMalicious Nodes: "+text[36]+"%"
|
2024-01-29 19:50:01 +05:30
|
|
|
conf["title"] = "Restore Column Count for Each Node"
|
|
|
|
conf["type"] = "individual_bar"
|
|
|
|
conf["legLoc"] = 1
|
|
|
|
conf["desLoc"] = 1
|
|
|
|
conf["xlabel"] = "Nodes"
|
|
|
|
conf["ylabel"] = "Restore Column Count"
|
|
|
|
conf["data"] = result.restoreColumnCount
|
|
|
|
conf["xdots"] = range(result.shape.numberNodes)
|
|
|
|
conf["path"] = plotPath + "/restoreColumnCount.png"
|
|
|
|
maxi = max(conf["data"])
|
|
|
|
conf["yaxismax"] = maxi
|
|
|
|
plotData(conf)
|
|
|
|
print("Plot %s created." % conf["path"])
|
|
|
|
|
2024-01-21 01:27:17 +05:30
|
|
|
def plotSampleRecv(self, result, plotPath):
|
|
|
|
"""Plots the percentage sampleRecv for each node"""
|
|
|
|
conf = {}
|
|
|
|
text = str(result.shape).split("-")
|
2024-02-18 22:16:16 +05:30
|
|
|
conf["textBox"] = "Row Size: "+text[2]+"\nColumn Size: "+text[6]+"\nNumber of nodes: "+text[10]\
|
2024-02-15 23:48:30 +05:30
|
|
|
+"\nFailure rate: "+text[14]+"%"+"\nNetwork degree: "+text[32]+"\nMalicious Nodes: "+text[36]+"%"
|
2024-01-21 01:27:17 +05:30
|
|
|
conf["title"] = "Percentage of Samples Received by Nodes"
|
2024-02-18 22:16:16 +05:30
|
|
|
conf["type"] = "individual_bar_with_2line"
|
2024-01-21 01:27:17 +05:30
|
|
|
conf["legLoc"] = 1
|
|
|
|
conf["desLoc"] = 1
|
|
|
|
conf["xlabel"] = "Nodes"
|
|
|
|
conf["ylabel"] = "Percentage of samples received (%)"
|
2024-02-15 23:48:30 +05:30
|
|
|
total_samples = result.shape.blockSizeR * result.shape.blockSizeC
|
2024-01-21 01:27:17 +05:30
|
|
|
percentage_data = [(count / total_samples) * 100 for count in result.sampleRecvCount]
|
|
|
|
conf["data"] = percentage_data
|
|
|
|
conf["xdots"] = range(result.shape.numberNodes)
|
|
|
|
conf["path"] = plotPath + "/sampleRecv.png"
|
|
|
|
maxi = max(conf["data"])
|
2024-02-18 22:51:19 +05:30
|
|
|
# conf["yaxismax"] = maxi * 1.1
|
2024-02-18 22:16:16 +05:30
|
|
|
expected_percentage1 = (result.shape.vpn1 * (result.shape.blockSizeR * result.shape.chiR + result.shape.blockSizeC * result.shape.chiC) * 100)/total_samples
|
|
|
|
expected_percentage2 = (result.shape.vpn2 * (result.shape.blockSizeR * result.shape.chiR + result.shape.blockSizeC * result.shape.chiC) * 100)/total_samples
|
|
|
|
if expected_percentage1 > 100:
|
|
|
|
expected_percentage1 = 100
|
|
|
|
if expected_percentage2 > 100:
|
|
|
|
expected_percentage2 = 100
|
|
|
|
conf["expected_value1"] = expected_percentage1
|
|
|
|
conf["expected_value2"] = expected_percentage2
|
2024-02-18 22:51:19 +05:30
|
|
|
conf["line_label1"] = "Expected Value for class 1 nodes"
|
2024-02-19 14:29:23 +05:30
|
|
|
conf["line_label2"] = "Expected Value for class 2 nodes"
|
2024-02-18 22:51:19 +05:30
|
|
|
conf["yaxismax"] = max(expected_percentage1, expected_percentage2) * 1.05
|
2024-01-21 01:27:17 +05:30
|
|
|
plotData(conf)
|
|
|
|
print("Plot %s created." % conf["path"])
|
|
|
|
|
2023-06-11 18:46:55 +02:00
|
|
|
def plotMissingSamples(self, result, plotPath):
|
2023-05-13 11:25:09 +02:00
|
|
|
"""Plots the missing samples in the network"""
|
|
|
|
conf = {}
|
|
|
|
text = str(result.shape).split("-")
|
2024-02-18 22:16:16 +05:30
|
|
|
conf["textBox"] = "Row Size: "+text[2]+"\nColumn Size: "+text[6]+"\nNumber of nodes: "+text[10]\
|
2024-02-15 23:48:30 +05:30
|
|
|
+"\nFailure rate: "+text[14]+"%"+"\nNetwork degree: "+text[32]+"\nMalicious Nodes: "+text[36]+"%"
|
2023-05-13 11:25:09 +02:00
|
|
|
conf["title"] = "Missing Samples"
|
2024-02-18 22:16:16 +05:30
|
|
|
conf["type"] = "plot_with_1line"
|
2023-05-13 11:25:09 +02:00
|
|
|
conf["legLoc"] = 1
|
|
|
|
conf["desLoc"] = 1
|
|
|
|
conf["colors"] = ["m-"]
|
|
|
|
conf["labels"] = ["Missing Samples"]
|
|
|
|
conf["xlabel"] = "Time (ms)"
|
|
|
|
conf["ylabel"] = "Number of Missing Samples"
|
|
|
|
conf["data"] = [result.missingVector]
|
|
|
|
conf["xdots"] = [x*self.config.stepDuration for x in range(len(result.missingVector))]
|
2023-06-11 18:46:55 +02:00
|
|
|
conf["path"] = plotPath+"/missingSamples.png"
|
2023-05-15 17:56:30 +02:00
|
|
|
maxi = 0
|
|
|
|
for v in conf["data"]:
|
|
|
|
if max(v) > maxi:
|
|
|
|
maxi = max(v)
|
|
|
|
conf["yaxismax"] = maxi
|
2024-02-18 22:16:16 +05:30
|
|
|
x = result.shape.blockSizeR * result.shape.chiR + result.shape.blockSizeC * result.shape.chiC
|
|
|
|
conf["expected_value"] = (result.shape.numberNodes - 1) * (result.shape.class1ratio * result.shape.vpn1 * x + (1 - result.shape.class1ratio) * result.shape.vpn2 * x)
|
2024-02-18 22:51:19 +05:30
|
|
|
conf["line_label"] = "Total samples to deliver"
|
2023-05-13 11:25:09 +02:00
|
|
|
plotData(conf)
|
|
|
|
print("Plot %s created." % conf["path"])
|
|
|
|
|
2023-06-11 18:46:55 +02:00
|
|
|
def plotProgress(self, result, plotPath):
|
2023-05-13 11:25:09 +02:00
|
|
|
"""Plots the percentage of nodes ready in the network"""
|
2024-01-21 01:27:17 +05:30
|
|
|
vector1 = [x * 100 for x in result.metrics["progress"]["nodes ready"]]
|
|
|
|
vector2 = [x * 100 for x in result.metrics["progress"]["validators ready"]]
|
|
|
|
vector3 = [x * 100 for x in result.metrics["progress"]["samples received"]]
|
2023-05-13 11:25:09 +02:00
|
|
|
conf = {}
|
|
|
|
text = str(result.shape).split("-")
|
2024-02-18 22:16:16 +05:30
|
|
|
conf["textBox"] = "Row Size: "+text[2]+"\nColumn Size: "+text[6]+"\nNumber of nodes: "+text[10]\
|
2024-02-15 23:48:30 +05:30
|
|
|
+"\nFailure rate: "+text[14]+"%"+"\nNetwork degree: "+text[32]+"\nMalicious Nodes: "+text[36]+"%"
|
2023-05-13 11:25:09 +02:00
|
|
|
conf["title"] = "Nodes/validators ready"
|
2023-05-15 17:56:30 +02:00
|
|
|
conf["type"] = "plot"
|
2023-05-13 11:25:09 +02:00
|
|
|
conf["legLoc"] = 2
|
|
|
|
conf["desLoc"] = 2
|
|
|
|
conf["colors"] = ["g-", "b-", "r-"]
|
|
|
|
conf["labels"] = ["Nodes", "Validators", "Samples"]
|
|
|
|
conf["xlabel"] = "Time (ms)"
|
|
|
|
conf["ylabel"] = "Percentage (%)"
|
|
|
|
conf["data"] = [vector1, vector2, vector3]
|
|
|
|
conf["xdots"] = [x*self.config.stepDuration for x in range(len(vector1))]
|
2023-06-11 18:46:55 +02:00
|
|
|
conf["path"] = plotPath+"/nodesReady.png"
|
2023-05-15 17:56:30 +02:00
|
|
|
maxi = 0
|
|
|
|
for v in conf["data"]:
|
|
|
|
if max(v) > maxi:
|
|
|
|
maxi = max(v)
|
|
|
|
conf["yaxismax"] = maxi
|
|
|
|
plotData(conf)
|
|
|
|
print("Plot %s created." % conf["path"])
|
|
|
|
|
2023-06-11 18:46:55 +02:00
|
|
|
def plotSentData(self, result, plotPath):
|
2023-05-15 17:56:30 +02:00
|
|
|
"""Plots the percentage of nodes ready in the network"""
|
|
|
|
vector1 = result.metrics["progress"]["TX builder mean"]
|
|
|
|
vector2 = result.metrics["progress"]["TX class1 mean"]
|
|
|
|
vector3 = result.metrics["progress"]["TX class2 mean"]
|
|
|
|
for i in range(len(vector1)):
|
|
|
|
vector1[i] = (vector1[i] * 8 * (1000/self.config.stepDuration) * self.config.segmentSize) / 1000000
|
|
|
|
vector2[i] = (vector2[i] * 8 * (1000/self.config.stepDuration) * self.config.segmentSize) / 1000000
|
|
|
|
vector3[i] = (vector3[i] * 8 * (1000/self.config.stepDuration) * self.config.segmentSize) / 1000000
|
|
|
|
conf = {}
|
|
|
|
text = str(result.shape).split("-")
|
2024-02-18 22:16:16 +05:30
|
|
|
conf["textBox"] = "Row Size: "+text[2]+"\nColumn Size: "+text[6]+"\nNumber of nodes: "+text[10]\
|
2024-02-15 23:48:30 +05:30
|
|
|
+"\nFailure rate: "+text[14]+"%"+"\nNetwork degree: "+text[32]+"\nMalicious Nodes: "+text[36]+"%"
|
2023-05-15 17:56:30 +02:00
|
|
|
conf["title"] = "Sent data"
|
|
|
|
conf["type"] = "plot"
|
|
|
|
conf["legLoc"] = 2
|
|
|
|
conf["desLoc"] = 2
|
|
|
|
conf["colors"] = ["y-", "c-", "m-"]
|
|
|
|
conf["labels"] = ["Block Builder", "Solo stakers", "Staking pools"]
|
|
|
|
conf["xlabel"] = "Time (ms)"
|
|
|
|
conf["ylabel"] = "Bandwidth (MBits/s)"
|
|
|
|
conf["data"] = [vector1, vector2, vector3]
|
|
|
|
conf["xdots"] = [x*self.config.stepDuration for x in range(len(vector1))]
|
2023-06-11 18:46:55 +02:00
|
|
|
conf["path"] = plotPath+"/sentData.png"
|
2023-05-15 17:56:30 +02:00
|
|
|
maxi = 0
|
|
|
|
for v in conf["data"]:
|
|
|
|
if max(v) > maxi:
|
|
|
|
maxi = max(v)
|
|
|
|
conf["yaxismax"] = maxi
|
|
|
|
plotData(conf)
|
|
|
|
print("Plot %s created." % conf["path"])
|
|
|
|
|
2023-06-11 18:46:55 +02:00
|
|
|
def plotRecvData(self, result, plotPath):
|
2023-05-15 17:56:30 +02:00
|
|
|
"""Plots the percentage of nodes ready in the network"""
|
|
|
|
vector1 = result.metrics["progress"]["RX class1 mean"]
|
|
|
|
vector2 = result.metrics["progress"]["RX class2 mean"]
|
|
|
|
for i in range(len(vector1)):
|
|
|
|
vector1[i] = (vector1[i] * 8 * (1000/self.config.stepDuration) * self.config.segmentSize) / 1000000
|
|
|
|
vector2[i] = (vector2[i] * 8 * (1000/self.config.stepDuration) * self.config.segmentSize) / 1000000
|
|
|
|
conf = {}
|
|
|
|
text = str(result.shape).split("-")
|
2024-02-18 22:16:16 +05:30
|
|
|
conf["textBox"] = "Row Size: "+text[2]+"\nColumn Size: "+text[6]+"\nNumber of nodes: "+text[10]\
|
2024-02-15 23:48:30 +05:30
|
|
|
+"\nFailure rate: "+text[14]+"%"+" \nNetwork degree: "+text[32]+"\nMalicious Nodes: "+text[36]+"%"
|
2023-05-15 17:56:30 +02:00
|
|
|
conf["title"] = "Received data"
|
|
|
|
conf["type"] = "plot"
|
|
|
|
conf["legLoc"] = 2
|
|
|
|
conf["desLoc"] = 2
|
|
|
|
conf["colors"] = ["c-", "m-"]
|
|
|
|
conf["labels"] = ["Solo stakers", "Staking pools"]
|
|
|
|
conf["xlabel"] = "Time (ms)"
|
|
|
|
conf["ylabel"] = "Bandwidth (MBits/s)"
|
|
|
|
conf["data"] = [vector1, vector2]
|
|
|
|
conf["xdots"] = [x*self.config.stepDuration for x in range(len(vector1))]
|
2023-06-11 18:46:55 +02:00
|
|
|
conf["path"] = plotPath+"/recvData.png"
|
2023-05-15 17:56:30 +02:00
|
|
|
maxi = 0
|
|
|
|
for v in conf["data"]:
|
|
|
|
if max(v) > maxi:
|
|
|
|
maxi = max(v)
|
|
|
|
conf["yaxismax"] = maxi
|
|
|
|
plotData(conf)
|
|
|
|
print("Plot %s created." % conf["path"])
|
|
|
|
|
2023-06-11 18:46:55 +02:00
|
|
|
def plotDupData(self, result, plotPath):
|
2023-05-15 17:56:30 +02:00
|
|
|
"""Plots the percentage of nodes ready in the network"""
|
|
|
|
vector1 = result.metrics["progress"]["Dup class1 mean"]
|
|
|
|
vector2 = result.metrics["progress"]["Dup class2 mean"]
|
|
|
|
for i in range(len(vector1)):
|
|
|
|
vector1[i] = (vector1[i] * 8 * (1000/self.config.stepDuration) * self.config.segmentSize) / 1000000
|
|
|
|
vector2[i] = (vector2[i] * 8 * (1000/self.config.stepDuration) * self.config.segmentSize) / 1000000
|
|
|
|
conf = {}
|
|
|
|
text = str(result.shape).split("-")
|
2024-02-18 22:16:16 +05:30
|
|
|
conf["textBox"] = "Row Size: "+text[2]+"\nColumn Size: "+text[6]+"\nNumber of nodes: "+text[10]\
|
2024-02-15 23:48:30 +05:30
|
|
|
+"\nFailure rate: "+text[14]+"%"+" \nNetwork degree: "+text[32]+"\nMalicious Nodes: "+text[36]+"%"
|
2023-05-15 17:56:30 +02:00
|
|
|
conf["title"] = "Duplicated data"
|
|
|
|
conf["type"] = "plot"
|
|
|
|
conf["legLoc"] = 2
|
|
|
|
conf["desLoc"] = 2
|
|
|
|
conf["colors"] = ["c-", "m-"]
|
|
|
|
conf["labels"] = ["Solo stakers", "Staking pools"]
|
|
|
|
conf["xlabel"] = "Time (ms)"
|
|
|
|
conf["ylabel"] = "Bandwidth (MBits/s)"
|
|
|
|
conf["data"] = [vector1, vector2]
|
|
|
|
conf["xdots"] = [x*self.config.stepDuration for x in range(len(vector1))]
|
2023-06-11 18:46:55 +02:00
|
|
|
conf["path"] = plotPath+"/dupData.png"
|
2023-05-15 17:56:30 +02:00
|
|
|
maxi = 0
|
|
|
|
for v in conf["data"]:
|
|
|
|
if max(v) > maxi:
|
|
|
|
maxi = max(v)
|
|
|
|
conf["yaxismax"] = maxi
|
|
|
|
plotData(conf)
|
|
|
|
print("Plot %s created." % conf["path"])
|
|
|
|
|
2023-06-11 18:46:55 +02:00
|
|
|
def plotRowCol(self, result, plotPath):
|
2023-05-15 17:56:30 +02:00
|
|
|
"""Plots the percentage of nodes ready in the network"""
|
|
|
|
vector1 = result.metrics["rowDist"]
|
|
|
|
vector2 = result.metrics["columnDist"]
|
2024-02-15 23:48:30 +05:30
|
|
|
if len(vector1) > len(vector2):
|
|
|
|
vector2 += [np.nan] * (len(vector1) - len(vector2))
|
|
|
|
elif len(vector1) < len(vector2):
|
|
|
|
vector1 += [np.nan] * (len(vector2) - len(vector1))
|
2023-05-15 17:56:30 +02:00
|
|
|
conf = {}
|
|
|
|
text = str(result.shape).split("-")
|
2024-02-18 22:16:16 +05:30
|
|
|
conf["textBox"] = "Row Size: "+text[2]+"\nColumn Size: "+text[6]+"\nNumber of nodes: "+text[10]\
|
2024-02-15 23:48:30 +05:30
|
|
|
+"\nFailure rate: "+text[14]+"%"+" \nNetwork degree: "+text[32]+"\nMalicious Nodes: "+text[36]+"%"
|
2023-05-15 17:56:30 +02:00
|
|
|
conf["title"] = "Row/Column distribution"
|
2024-01-21 01:27:17 +05:30
|
|
|
conf["type"] = "grouped_bar"
|
2023-05-15 17:56:30 +02:00
|
|
|
conf["legLoc"] = 2
|
|
|
|
conf["desLoc"] = 2
|
|
|
|
conf["colors"] = ["r+", "b+"]
|
|
|
|
conf["labels"] = ["Rows", "Columns"]
|
|
|
|
conf["xlabel"] = "Row/Column ID"
|
|
|
|
conf["ylabel"] = "Validators subscribed"
|
|
|
|
conf["data"] = [vector1, vector2]
|
|
|
|
conf["xdots"] = range(len(vector1))
|
2023-06-11 18:46:55 +02:00
|
|
|
conf["path"] = plotPath+"/RowColDist.png"
|
2023-05-15 17:56:30 +02:00
|
|
|
maxi = 0
|
|
|
|
for v in conf["data"]:
|
2024-02-15 23:48:30 +05:30
|
|
|
if np.nanmax(v) > maxi:
|
2023-05-15 17:56:30 +02:00
|
|
|
maxi = max(v)
|
|
|
|
conf["yaxismax"] = maxi
|
2023-05-13 11:25:09 +02:00
|
|
|
plotData(conf)
|
|
|
|
print("Plot %s created." % conf["path"])
|
|
|
|
|
2024-01-21 01:27:17 +05:30
|
|
|
def plotMessagesSent(self, result, plotPath):
|
|
|
|
"""Plots the number of messages sent by all nodes"""
|
|
|
|
conf = {}
|
|
|
|
text = str(result.shape).split("-")
|
2024-02-18 22:16:16 +05:30
|
|
|
conf["textBox"] = "Row Size: "+text[2]+"\nColumn Size: "+text[6]+"\nNumber of nodes: "+text[10]\
|
2024-02-15 23:48:30 +05:30
|
|
|
+"\nFailure rate: "+text[14]+"%"+" \nNetwork degree: "+text[32]+"\nMalicious Nodes: "+text[36]+"%"
|
2024-01-21 01:27:17 +05:30
|
|
|
conf["title"] = "Number of Messages Sent by Nodes"
|
|
|
|
conf["type"] = "individual_bar"
|
|
|
|
conf["legLoc"] = 1
|
|
|
|
conf["desLoc"] = 1
|
|
|
|
conf["xlabel"] = "Nodes"
|
|
|
|
conf["ylabel"] = "Number of Messages Sent"
|
|
|
|
conf["data"] = result.msgSentCount
|
|
|
|
conf["xdots"] = range(result.shape.numberNodes)
|
|
|
|
conf["path"] = plotPath + "/messagesSent.png"
|
|
|
|
maxi = max(conf["data"])
|
|
|
|
conf["yaxismax"] = maxi
|
|
|
|
plotData(conf)
|
|
|
|
print("Plot %s created." % conf["path"])
|
|
|
|
|
|
|
|
def plotMessagesRecv(self, result, plotPath):
|
|
|
|
"""Plots the number of messages received by all nodes"""
|
|
|
|
conf = {}
|
|
|
|
text = str(result.shape).split("-")
|
2024-02-18 22:16:16 +05:30
|
|
|
conf["textBox"] = "Row Size: "+text[2]+"\nColumn Size: "+text[6]+"\nNumber of nodes: "+text[10]\
|
2024-02-15 23:48:30 +05:30
|
|
|
+"\nFailure rate: "+text[14]+"%"+"\nNetwork degree: "+text[32]+"\nMalicious Nodes: "+text[36]+"%"
|
2024-01-21 01:27:17 +05:30
|
|
|
conf["title"] = "Number of Messages Received by Nodes"
|
|
|
|
conf["type"] = "individual_bar"
|
|
|
|
conf["legLoc"] = 1
|
|
|
|
conf["desLoc"] = 1
|
|
|
|
conf["xlabel"] = "Nodes"
|
|
|
|
conf["ylabel"] = "Number of Messages Received"
|
|
|
|
conf["data"] = result.msgRecvCount
|
|
|
|
conf["xdots"] = range(result.shape.numberNodes)
|
|
|
|
conf["path"] = plotPath + "/messagesRecv.png"
|
|
|
|
maxi = max(conf["data"])
|
|
|
|
conf["yaxismax"] = maxi
|
|
|
|
plotData(conf)
|
|
|
|
print("Plot %s created." % conf["path"])
|