diff --git a/.gitignore b/.gitignore index 0ddc37c..13af17b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ graphs/venv/ +graphs/figs/ +graphs/__pycache__/ diff --git a/graphs/build.py b/graphs/build.py new file mode 100644 index 0000000..cf63d3b --- /dev/null +++ b/graphs/build.py @@ -0,0 +1,15 @@ +import rtt +import ric +import ram +import cpu +import iperf +import ping +import retransmissions + +rtt.build() +ric.build() +ram.build() +cpu.build() +iperf.build() +ping.build() +retransmissions.build() diff --git a/graphs/cpu.py b/graphs/cpu.py index fbbcdbb..65fc9cd 100644 --- a/graphs/cpu.py +++ b/graphs/cpu.py @@ -2,7 +2,6 @@ import matplotlib.pyplot as plt import matplotlib as mpl -mpl.use('QtAgg') files = [ [ "../logs/oai/oai/iperf/cpu-ran.csv", @@ -33,7 +32,7 @@ ], ] -rans = ["OAI", "srsRAN"] +rans = ["OAI RAN", "srsRAN"] cores = [ "OAI CN", @@ -49,24 +48,34 @@ def readfile(file: str, skip: int): return data -# there are 40 measurements total. They were taken every 15s -# so in total the test lasted 600s -x = np.arange(40) * 15 # the label locations +def build(save=True): + # there are 40 measurements total. They were taken every 15s + # so in total the test lasted 600s + x = np.arange(40) * 15 # the label locations -colors = ["#7EA16B", "#C3D898"] -fig, axes = plt.subplots(1, 3, layout='constrained') + colors = ["#7EA16B", "#C3D898"] + fig, axes = plt.subplots(1, 3, layout='constrained') -for tests, offsets, ax, core in zip(files, skip, axes, cores): - ax.set_ylim(0, 12) - for ran, color, test, offset in zip(rans, colors, tests, offsets): - data = readfile(test, offset) - rects = ax.plot(x, data, label=ran, color=color) - ax.set_xlabel(core, fontsize=12) + for tests, offsets, ax, core in zip(files, skip, axes, cores): + ax.set_ylim(0, 12) + for ran, color, test, offset in zip(rans, colors, tests, offsets): + data = readfile(test, offset) + rects = ax.plot(x, data, label=ran, color=color) + ax.set_xlabel(core, fontsize=12) # Add some text for labels, title and custom x-axis tick labels, etc. -fig.supylabel('Consumo de CPU (%)', fontsize=14) + fig.supylabel('Consumo de CPU (%)', fontsize=14) #axes[len(axes)//2].set_xlabel("Tempo (s)", fontsize=14) -axes[-1].legend(loc='upper right', ncols=2, fontsize=12) -fig.supxlabel("Tempo (s)", fontsize=14) + axes[-1].legend(loc='upper right', ncols=2, fontsize=12) + fig.supxlabel("Tempo (s)", fontsize=14) -plt.show() +#fig.set_tight_layout() + fig.set_size_inches(10.4, 4.2) +#plt.show() + if save: + fig.savefig("figs/cpu.pdf", dpi=100) + +if __name__ == "__main__": + build(False) + mpl.use('QtAgg') + plt.show() diff --git a/graphs/iperf.py b/graphs/iperf.py index 7ee491f..84d99f5 100644 --- a/graphs/iperf.py +++ b/graphs/iperf.py @@ -4,7 +4,6 @@ import matplotlib as mpl import json -mpl.use('QtAgg') files = ["../logs/oai/oai/iperf/oai-oaicn", "../logs/srsran/oai/iperf/20240304-oai", "../logs/oai/open5gs/iperf/oai-open5gs", @@ -18,7 +17,7 @@ "Free5Gc", ] rans = [ - "OAI", + "OAI RAN", "srsRAN", "_OAI", "_srsRAN", @@ -26,7 +25,7 @@ "_srsRAN", ] count = len(files) -ax = plt.subplot() +fig, ax = plt.subplots(1,1) def conv(x): return float(x['sum']['bits_per_second'])/1_000_000 @@ -34,23 +33,33 @@ def conv(x): def from_iter(x): return np.fromiter(map(conv, x['intervals']), float) -ax.set_ylabel("Taxa de transferência (Mbps)", fontsize=14) +def build(save=True): + ax.set_ylabel("Taxa de Transferência (Mbps)", fontsize=16) -dataset = [] -for i in range(count): - with open(files[i], "r") as file: - data = json.load(file) - dataset.append(list(from_iter(data))) + dataset = [] + for i in range(count): + with open(files[i], "r") as file: + data = json.load(file) + dataset.append(list(from_iter(data))) -colors = ["#7EA16B", "#C3D898"] -b = ax.boxplot(dataset, labels=rans, medianprops={"color": "#000000"}) -for i in range(len(b['boxes'])): - box = b['boxes'][i] - ax.add_patch(Polygon(box.get_xydata(), facecolor=colors[i%2], label=rans[i])) + colors = ["#7EA16B", "#C3D898"] + b = ax.boxplot(dataset, labels=rans, medianprops={"color": "#000000"}) + for i in range(len(b['boxes'])): + box = b['boxes'][i] + ax.add_patch(Polygon(box.get_xydata(), facecolor=colors[i%2], label=rans[i])) -x = np.arange(len(labels)) * 2 + 1.5 -ax.set_xticks(x, labels, fontsize=12) -ax.set_ylim((50,130)) -ax.legend(loc='upper right', ncols=2, fontsize=12) + x = np.arange(len(labels)) * 2 + 1.5 + ax.set_xticks(x, labels, fontsize=16) + ax.set_ylim((50,130)) + ax.legend(loc='upper right', ncols=2, fontsize=14) -plt.show() + fig.set_size_inches(10.4, 4.2) + plt.tight_layout() +#plt.show() + if save: + fig.savefig("figs/iperf.pdf", dpi=100) + +if __name__ == "__main__": + build(save=False) + mpl.use('QtAgg') + plt.show() diff --git a/graphs/ping.py b/graphs/ping.py index 289a5e1..7434aab 100644 --- a/graphs/ping.py +++ b/graphs/ping.py @@ -3,7 +3,6 @@ from matplotlib.patches import Polygon import matplotlib as mpl -mpl.use('QtAgg') NUM_ROWS = 600 def conv(x: str): @@ -30,30 +29,41 @@ def read_file(path: str): "Free5Gc", ] rans = [ - "OAI", + "OAI RAN", "srsRAN", "_OAI", "_srsRAN", "_OAI", "_srsRAN", ] -count = len(paths) -ax = plt.subplot() +def build(save=True): + count = len(paths) + fig, ax = plt.subplots(1,1) -dataset = list(map(lambda path: read_file(path), paths)) -ax.set_ylabel("Latência (ms)", fontsize=14) -ax.set_ylim((0, 64)) -colors = ["#7EA16B", "#C3D898"] -b = ax.boxplot(dataset, labels=rans, medianprops={"color": "#000000"}) -for i in range(len(b['boxes'])): - box = b['boxes'][i] - ax.add_patch(Polygon(box.get_xydata(), facecolor=colors[i%2], label=rans[i])) -x = np.arange(len(labels)) * 2 + 1.5 -ax.set_xticks(x, labels, fontsize=12) + dataset = list(map(lambda path: read_file(path), paths)) + ax.set_ylabel("Latência (ms)", fontsize=16) + ax.set_ylim((0, 64)) + colors = ["#7EA16B", "#C3D898"] + b = ax.boxplot(dataset, labels=rans, medianprops={"color": "#000000"}) + for i in range(len(b['boxes'])): + box = b['boxes'][i] + ax.add_patch(Polygon(box.get_xydata(), facecolor=colors[i%2], label=rans[i])) -ax.legend(loc='upper right', ncols=2, fontsize=12) + x = np.arange(len(labels)) * 2 + 1.5 + ax.set_xticks(x, labels, fontsize=16) -plt.show() + ax.legend(loc='upper right', ncols=2, fontsize=14) + + fig.set_size_inches(10.4, 4.2) + plt.tight_layout() +#plt.show() + if save: + fig.savefig("figs/ping.pdf", dpi=100) + +if __name__ == "__main__": + build(False) + mpl.use('QtAgg') + plt.show() diff --git a/graphs/ram-boxplot.py b/graphs/ram-boxplot.py deleted file mode 100644 index 1ace781..0000000 --- a/graphs/ram-boxplot.py +++ /dev/null @@ -1,86 +0,0 @@ -import numpy as np -import matplotlib.pyplot as plt -import matplotlib as mpl -from itertools import cycle -from matplotlib.patches import Polygon - - -mpl.use('QtAgg') -files = [ - "../logs/oai/oai/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 15 53 24.csv", # core - "../logs/oai/oai/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 15 52 37.csv", # RAN - "../logs/srsran/oai/iperf/core/Memory Basic-data-as-joinbyfield-2024-03-04 17 44 59.csv", # core - "../logs/srsran/oai/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 17 43 53.csv", # RAN - "../logs/oai/open5gs/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 16 21 22.csv", # core - "../logs/oai/open5gs/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 16 21 00.csv", # RAN - "../logs/srsran/open5gs/iperf/Memory Basic-data-as-joinbyfield-2024-03-20 17 22 53.csv", # core - "../logs/srsran/open5gs/iperf/Memory Basic-data-as-joinbyfield-2024-03-20 17 23 19.csv", # RAN - "../logs/oai/free5gc/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 18 44 19.csv", # core - "../logs/oai/free5gc/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 18 45 26.csv", # RAN - "../logs/srsran/free5gc/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 18 13 53.csv", # core - "../logs/srsran/free5gc/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 18 13 29.csv", # RAN -] -# how many samples to skip until the start of the experiment -skips = [ - 14, - 14, - 9, - 10, - 16, - 17, - 16, - 13, - 18, - 13, - 16, - 18, -] -labels = [ - "OAI CN", - "Open5Gs", - "Free5Gc", -] - -rans = [ - "OAI", - "OAI (core)", - "srsRAN", - "srsRAN (core)", - "_OAI", - "_OAI", - "_srsRAN", - "_srsRAN", - "_OAI", - "_OAI", - "_srsRAN", - "_srsRAN", - ] - -def conv(x): - return float(x[:-4]) - -def readfile(file: str, skip: int): - data = np.genfromtxt(file, delimiter=",", skip_header=skip, max_rows=40, usecols=[2], converters={2: conv}) - return data - - -colors = ["#7EA16B", "#7EA16B", "#C3D898", "#C3D898"] -fig, ax = plt.subplots(layout='constrained') - -data = [] -for file, skip in zip(files, skips): - data.append(readfile(file, skip)) - -b = ax.boxplot(data, labels=rans, medianprops={"color": "#000000"}) - -for box, ran, color, hatch in zip(b['boxes'], rans, cycle(colors), cycle(['/', ''])): - ax.add_patch(Polygon(box.get_xydata(), facecolor=color, label=ran, hatch=hatch)) - -# Add some text for labels, title and custom x-axis tick labels, etc. -ax.set_ylabel('Comsumo de memória no núcleo (GB)', fontsize=14) -x = np.arange(len(labels)) * 4 + 2.5 -ax.set_xticks(x, labels, fontsize=12) -ax.set_ylim(0, 10) -ax.legend(loc='upper right', ncols=2, fontsize=12) - -plt.show() diff --git a/graphs/ram-core-boxplot.py b/graphs/ram-core-boxplot.py deleted file mode 100644 index 1a36c77..0000000 --- a/graphs/ram-core-boxplot.py +++ /dev/null @@ -1,72 +0,0 @@ -import numpy as np -import matplotlib.pyplot as plt -import matplotlib as mpl -from itertools import cycle - -mpl.use('QtAgg') -files = [ - "../logs/oai/oai/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 15 53 24.csv", # core - #"../logs/oai/oai/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 15 52 37.csv", # RAN - "../logs/srsran/oai/iperf/core/Memory Basic-data-as-joinbyfield-2024-03-04 17 44 59.csv", # core - #"../logs/srsran/oai/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 17 43 53.csv", # RAN - "../logs/oai/open5gs/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 16 21 22.csv", # core - #"../logs/oai/open5gs/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 16 21 00.csv", # RAN - "../logs/srsran/open5gs/iperf/Memory Basic-data-as-joinbyfield-2024-03-20 17 22 53.csv", # core - #"../logs/srsran/open5gs/iperf/Memory Basic-data-as-joinbyfield-2024-03-20 17 23 19.csv", # RAN - "../logs/oai/free5gc/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 18 44 19.csv", # core - #"../logs/oai/free5gc/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 18 45 26.csv", # RAN - "../logs/srsran/free5gc/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 18 13 53.csv", # core - #"../logs/srsran/free5gc/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 18 13 29.csv", # RAN -] -# how many samples to skip until the start of the experiment -skips = [ - 14, - 9, - 16, - 16, - 18, - 16, -] -labels = [ - "OAI CN", - "Open5Gs", - "Free5Gc", -] - -rans = [ - "OAI", - "srsRAN", - "_OAI", - "_srsRAN", - "_OAI", - "_srsRAN", - ] - -def conv(x): - return float(x[:-4]) - -def readfile(file: str, skip: int): - data = np.genfromtxt(file, delimiter=",", skip_header=skip, max_rows=40, usecols=[2], converters={2: conv}) - return data - - -colors = ["#7EA16B", "#C3D898"] -fig, ax = plt.subplots(layout='constrained') - -data = [] -for file, skip in zip(files, skips): - data.append(readfile(file, skip)) - -b = ax.boxplot(data, labels=rans, medianprops={"color": "#000000"}) -for box, ran, color in zip(b['boxes'], rans, cycle(colors)): - box.set_gapcolor(color) - box.set_label(ran) - -# Add some text for labels, title and custom x-axis tick labels, etc. -ax.set_ylabel('Comsumo de memória no núcleo (GB)', fontsize=14) -x = np.arange(len(labels)) * 2 + 1.5 -ax.set_xticks(x, labels, fontsize=12) -ax.set_ylim(0, 2) -ax.legend(loc='upper right', ncols=2, fontsize=12) - -plt.show() diff --git a/graphs/ram-errorbar-core.py b/graphs/ram-errorbar-core.py deleted file mode 100644 index 48b6c2d..0000000 --- a/graphs/ram-errorbar-core.py +++ /dev/null @@ -1,66 +0,0 @@ -import numpy as np -import matplotlib.pyplot as plt -import matplotlib as mpl -from itertools import cycle -from matplotlib.patches import Polygon - - -mpl.use('QtAgg') -files = [ - "../logs/oai/oai/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 15 53 24.csv", # core - "../logs/srsran/oai/iperf/core/Memory Basic-data-as-joinbyfield-2024-03-04 17 44 59.csv", # core - "../logs/oai/open5gs/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 16 21 22.csv", # core - "../logs/srsran/open5gs/iperf/Memory Basic-data-as-joinbyfield-2024-03-20 17 22 53.csv", # core - "../logs/oai/free5gc/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 18 44 19.csv", # core - "../logs/srsran/free5gc/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 18 13 53.csv", # core -] -# how many samples to skip until the start of the experiment -skips = [ - 14, - 9, - 16, - 16, - 18, - 16, -] -labels = [ - "OAI CN", - "Open5Gs", - "Free5Gc", -] - -rans = [ - "OAI", - "srsRAN", - "_OAI", - "_srsRAN", - "_OAI", - "_srsRAN", - ] - -def conv(x): - return float(x[:-4]) - -def readfile(file: str, skip: int): - data = np.genfromtxt(file, delimiter=",", skip_header=skip, max_rows=40, usecols=[2], converters={2: conv}) - return data - - -colors = ["#7EA16B", "#C3D898"] -fig, ax = plt.subplots(layout='constrained') - -xaxis = np.arange(len(files)) -for file, skip, x, color, ran in zip(files, skips, xaxis, cycle(colors), rans): - data = readfile(file, skip) - median = np.median(data) - stddev = np.std(data) - ax.errorbar(x, median, yerr=stddev, label=ran, color=color, capsize=3.0, linewidth=4.2, capthick=4.2) - -# Add some text for labels, title and custom x-axis tick labels, etc. -ax.set_ylabel('Comsumo de memória no núcleo (GB)', fontsize=14) -x = np.arange(len(labels))*2 + 0.5 -ax.set_xticks(x, labels, fontsize=12) -ax.set_ylim(1.1, 1.4) -ax.legend(loc='upper right', ncols=2, fontsize=12) - -plt.show() diff --git a/graphs/ram-errorbar.py b/graphs/ram-errorbar.py deleted file mode 100644 index f82373c..0000000 --- a/graphs/ram-errorbar.py +++ /dev/null @@ -1,85 +0,0 @@ -import numpy as np -import matplotlib.pyplot as plt -import matplotlib as mpl -from itertools import cycle -from matplotlib.patches import Polygon - - -mpl.use('QtAgg') -files = [ - "../logs/oai/oai/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 15 53 24.csv", # core - "../logs/oai/oai/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 15 52 37.csv", # RAN - "../logs/srsran/oai/iperf/core/Memory Basic-data-as-joinbyfield-2024-03-04 17 44 59.csv", # core - "../logs/srsran/oai/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 17 43 53.csv", # RAN - "../logs/oai/open5gs/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 16 21 22.csv", # core - "../logs/oai/open5gs/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 16 21 00.csv", # RAN - "../logs/srsran/open5gs/iperf/Memory Basic-data-as-joinbyfield-2024-03-20 17 22 53.csv", # core - "../logs/srsran/open5gs/iperf/Memory Basic-data-as-joinbyfield-2024-03-20 17 23 19.csv", # RAN - "../logs/oai/free5gc/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 18 44 19.csv", # core - "../logs/oai/free5gc/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 18 45 26.csv", # RAN - "../logs/srsran/free5gc/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 18 13 53.csv", # core - "../logs/srsran/free5gc/iperf/Memory Basic-data-as-joinbyfield-2024-03-04 18 13 29.csv", # RAN -] -# how many samples to skip until the start of the experiment -skips = [ - 14, - 14, - 9, - 10, - 16, - 17, - 16, - 13, - 18, - 13, - 16, - 18, -] -labels = [ - "OAI CN", - "Open5Gs", - "Free5Gc", -] - -rans = [ - "OAI", - "OAI (core)", - "srsRAN", - "srsRAN (core)", - "_OAI", - "_OAI", - "_srsRAN", - "_srsRAN", - "_OAI", - "_OAI", - "_srsRAN", - "_srsRAN", - ] - -def conv(x): - return float(x[:-4]) - -def readfile(file: str, skip: int): - data = np.genfromtxt(file, delimiter=",", skip_header=skip, max_rows=40, usecols=[2], converters={2: conv}) - return data - - -colors = ["#7EA16B", "#7EA16B", "#C3D898", "#C3D898"] -ecolors = ["#cccccc", "#000000"] -fig, ax = plt.subplots(layout='constrained') - -xaxis = np.arange(len(files)) -for file, skip, x, color, ran, ecolor in zip(files, skips, xaxis, cycle(colors), rans, cycle(ecolors)): - data = readfile(file, skip) - median = np.median(data) - stddev = np.std(data) - ax.errorbar(x, median, yerr=stddev, label=ran, color=color, capsize=3.0, ecolor=ecolor) - -# Add some text for labels, title and custom x-axis tick labels, etc. -ax.set_ylabel('Comsumo de memória no núcleo (GB)', fontsize=14) -x = np.arange(len(labels)) * 4 + 1.5 -ax.set_xticks(x, labels, fontsize=12) -ax.set_ylim(0, 10) -ax.legend(loc='upper right', ncols=2, fontsize=12) - -plt.show() diff --git a/graphs/ram.py b/graphs/ram.py index db07cf8..7ac02d9 100644 --- a/graphs/ram.py +++ b/graphs/ram.py @@ -2,7 +2,6 @@ import matplotlib.pyplot as plt import matplotlib as mpl -mpl.use('QtAgg') files = [ #"../logs/oai/oai/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 15 53 24.csv", # core "../logs/oai/oai/iperf/Memory Basic-data-as-joinbyfield-2024-03-05 15 52 37.csv", # RAN @@ -32,34 +31,48 @@ "Free5Gc", ] -rans = ["OAI", "srsRAN"] +rans = [ + "OAI RAN", "srsRAN", + "_OAI", "_srsRAN", + "_OAI", "_srsRAN", +] def conv(x): return float(x[:-4]) def readfile(file: str, skip: int): data = np.genfromtxt(file, delimiter=",", skip_header=skip, max_rows=40, usecols=[2], converters={2: conv}) - return np.average(data) + return (np.average(data), np.std(data)) -x = np.arange(len(labels)) # the label locations -width = 0.33 # the width of the bars -multiplier = 0 +def build(save=True): + x = np.arange(len(labels)) + width = 0.33 # the width of the bars + multiplier = 0 -colors = ["#7EA16B", "#C3D898"] -fig, ax = plt.subplots(layout='constrained') + colors = ["#7EA16B", "#C3D898"] + fig, ax = plt.subplots(layout='constrained') -for i in range(len(rans)): - offset = width * multiplier - data = (readfile(files[i], skip[i]), readfile(files[i+2], skip[i+2]), readfile(files[i+4], skip[i+4])) - rects = ax.bar(x + offset, data, width, label=rans[i], color=colors[i]) - ax.bar_label(rects, padding=2) - multiplier += 1 + for i in range(len(files)): + offset = width * multiplier + data = readfile(files[i], skip[i]) + rects = ax.bar(offset, data[0], width, yerr=data[1], label=rans[i], color=colors[i%2]) + if i & 1 == 1: + multiplier += 1 + multiplier += 1 # Add some text for labels, title and custom x-axis tick labels, etc. -ax.set_ylabel('Consumo de mémoria na RAN (GB)', fontsize=14) -ax.set_xticks(x + width/2, labels, fontsize=12) -ax.set_ylim(0, 10) -ax.legend(loc='upper right', ncols=2, fontsize=12) + ax.set_ylabel('Consumo de Mémoria (GB)', fontsize=14) + ax.set_xticks(x + width/2, labels, fontsize=12) + ax.set_ylim(0, 10) + ax.legend(loc='upper right', ncols=2, fontsize=12) -plt.show() +#fig.set_tight_layout() + fig.set_size_inches(8, 4.2) +#plt.show() + if save: + fig.savefig("figs/ram.pdf", dpi=100) +if __name__ == "__main__": + build(False) + mpl.use('QtAgg') + plt.show() diff --git a/graphs/retransmissions.py b/graphs/retransmissions.py index c1e92eb..d4f4049 100644 --- a/graphs/retransmissions.py +++ b/graphs/retransmissions.py @@ -3,7 +3,6 @@ import matplotlib as mpl import json -mpl.use('QtAgg') files = ["../logs/oai/oai/iperf/oai-oaicn", "../logs/srsran/oai/iperf/20240304-oai", "../logs/oai/open5gs/iperf/oai-open5gs", @@ -17,7 +16,7 @@ "Free5Gc", ] -rans = ["OAI", "srsRAN"] +rans = ["OAI RAN", "srsRAN"] def conv(x): return (x['end']['sum_sent']['retransmits'] * 1358) / x['end']['sum_sent']['bytes'] @@ -27,26 +26,32 @@ def readfile(file): data = json.load(file) return conv(data) +def build(save=True): + x = np.arange(len(labels)) # the label locations + width = 0.33 # the width of the bars + multiplier = 0 -x = np.arange(len(labels)) # the label locations -width = 0.33 # the width of the bars -multiplier = 0 + colors = ["#7EA16B", "#C3D898"] + fig, ax = plt.subplots(layout='constrained') -colors = ["#7EA16B", "#C3D898"] -fig, ax = plt.subplots(layout='constrained') - -for i in range(len(rans)): - offset = width * multiplier - index = i - data = (readfile(files[index]), readfile(files[index+2]), readfile(files[index+4])) - rects = ax.bar(x + offset, data, width, label=rans[i], color=colors[i]) - ax.bar_label(rects, padding=2) - multiplier += 1 + for i in range(len(rans)): + offset = width * multiplier + index = i + data = (readfile(files[index]), readfile(files[index+2]), readfile(files[index+4])) + rects = ax.bar(x + offset, data, width, label=rans[i], color=colors[i]) + multiplier += 1 # Add some text for labels, title and custom x-axis tick labels, etc. -ax.set_ylabel('Número de pacotes retransmitidos', fontsize=14) -ax.set_xticks(x + width/2, labels, fontsize=12) -ax.set_ylim(0, 0.001) -ax.legend(loc='upper right', ncols=2, fontsize=12) - -plt.show() + ax.set_ylabel('Taxa Retransmissão de Pacotes (%)', fontsize=14) + ax.set_xticks(x + width/2, labels, fontsize=12) + ax.set_ylim(0, 0.001) + ax.legend(loc='upper right', ncols=2, fontsize=12) + fig.set_size_inches(8, 4.2) +#plt.show() + if save: + fig.savefig("figs/retrans.pdf", dpi=100) + +if __name__ == "__main__": + build(False) + mpl.use('QtAgg') + plt.show() diff --git a/graphs/ric-sep.py b/graphs/ric-sep.py deleted file mode 100644 index cfd61ae..0000000 --- a/graphs/ric-sep.py +++ /dev/null @@ -1,56 +0,0 @@ -from matplotlib.patches import Polygon -import matplotlib.pyplot as plt -import matplotlib as mpl - -mpl.use('QtAgg') -charts = [ - [ - "../logs/oai-flexric-values-only.log", - "../logs/srsran-flexric.logs", - ], - ["../logs/bouncer-values-only.log",] -] -labels = [ - "Flexric", - "ORAN SC RIC", -] -rans = [ - ["OAI RAN", - "srsRAN",], - ["srsRAN",], -] -limits = [ - (0, 4000), - (0, 1_200), -] - -ylabels = [ - "Tempo de Resposta (μs)", - "Tempo de Resposta (ms)", -] - -scaling_factor = [ - 1, - 1_000, -] - -fig, axes = plt.subplots(1, len(charts)) - - -colors = [["#7EA16B", "#C3D898",], ["#C3D898"],] -for files, ax, label, ran, color, limit, ylabel, sf in zip(charts, axes, labels, rans, colors, limits, ylabels, scaling_factor): - dataset = [] - for file in files: - with open(file, "r") as file: - data = map(lambda line: int(line[:-1])/sf, file.readlines()) - dataset.append(list(data)) - b = ax.boxplot(dataset, medianprops={"color": "#000000"}, widths=0.8) - for box, c, r in zip(b['boxes'], color, ran): - ax.add_patch(Polygon(box.get_xydata(), facecolor=c, label=r)) - ax.legend(loc='upper right', ncols=2, fontsize=12) - ax.set_ylim(limit) - ax.set_xlabel(label) - ax.set_ylabel(ylabel, fontsize=14) - ax.set_xticks([]) - -plt.show() diff --git a/graphs/ric.py b/graphs/ric.py index 7ebafa7..2746691 100644 --- a/graphs/ric.py +++ b/graphs/ric.py @@ -1,42 +1,66 @@ from matplotlib.patches import Polygon -import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl -mpl.use('QtAgg') -files = [ +charts = [ + [ "../logs/oai-flexric-values-only.log", "../logs/srsran-flexric.logs", - "../logs/bouncer-values-only.log", + ], + ["../logs/bouncer-values-only.log",] ] labels = [ - "Flexric", "Flexric", "ORAN SC RIC", ] rans = [ - "OAI", - "srsRAN", - "_srsRAN", + ["OAI RAN", + "srsRAN",], + ["srsRAN",], +] +limits = [ + (0, 4000), + (0, 1_200), +] + +ylabels = [ + "Tempo de Resposta (μs)", + "Tempo de Resposta (ms)", ] -count = len(files) -ax = plt.subplot() -ax.set_ylabel("Tempo de Resposta (us)", fontsize=14) +scaling_factor = [ + 1, + 1_000, +] + +def build(save=True): + fig, axes = plt.subplots(1, len(charts)) + -dataset = [] -for i in range(count): - with open(files[i], "r") as file: - data = map(lambda line: int(line[:-1]), file.readlines()) - dataset.append(list(data)) + colors = [["#7EA16B", "#C3D898",], ["#C3D898"],] + for files, ax, label, ran, color, limit, ylabel, sf in zip(charts, axes, labels, rans, colors, limits, ylabels, scaling_factor): + dataset = [] + for file in files: + with open(file, "r") as file: + data = map(lambda line: int(line[:-1])/sf, file.readlines()) + dataset.append(list(data)) + b = ax.boxplot(dataset, medianprops={"color": "#000000"}, widths=0.25*len(files)) + for box, c, r in zip(b['boxes'], color, ran): + ax.add_patch(Polygon(box.get_xydata(), facecolor=c, label=r)) + ax.legend(loc='upper right', ncols=2, fontsize=12) + ax.set_ylim(limit) + ax.set_xlabel(label, fontsize=14) + ax.set_ylabel(ylabel, fontsize=14) + ax.set_xticks([]) -colors = ["#7EA16B", "#C3D898", "#C3D898"] -b = ax.boxplot(dataset, labels=rans, medianprops={"color": "#000000"}) -for box, color, ran in zip(b['boxes'], colors, rans): - ax.add_patch(Polygon(box.get_xydata(), facecolor=color, label=ran)) + fig.tight_layout(pad=0.1) -x = np.arange(len(labels)) + 1 -ax.set_xticks(x, labels, fontsize=12) -ax.legend(loc='upper right', ncols=2, fontsize=12) + fig.set_size_inches(8, 4.2) +#plt.show() + if save: + fig.savefig("figs/ric.pdf", dpi=100) -plt.show() +if __name__ == "__main__": + build(False) + mpl.use('QtAgg') + plt.show() diff --git a/graphs/rtt.py b/graphs/rtt.py index a0fc26e..d569772 100644 --- a/graphs/rtt.py +++ b/graphs/rtt.py @@ -4,7 +4,6 @@ import matplotlib as mpl import json -mpl.use('QtAgg') files = ["../logs/oai/oai/iperf/oai-oaicn", "../logs/srsran/oai/iperf/20240304-oai", "../logs/oai/open5gs/iperf/oai-open5gs", @@ -18,7 +17,7 @@ "Free5Gc", ] rans = [ - "OAI", + "OAI RAN", "srsRAN", "_OAI", "_srsRAN", @@ -26,9 +25,6 @@ "_srsRAN", ] -count = len(files) -total_count = len(labels) -ax = plt.subplot() def conv(x): stream = x['streams'][0] @@ -38,22 +34,37 @@ def conv(x): def from_iter(x): return [conv(t) for t in x['intervals']] -ax.set_ylabel("Tempo de ida e volta (ms)", fontsize=14) +def build(save=True): + count = len(files) + total_count = len(labels) + fig, ax = plt.subplots(1,1) + fig.supylabel("Tempo de Ida e Volta (ms)", fontsize=16) -dataset = [] -for i in range(count): - with open(files[i], "r") as file: - data = json.load(file) - dataset.append(list(from_iter(data))) + dataset = [] + for i in range(count): + with open(files[i], "r") as file: + data = json.load(file) + dataset.append(list(from_iter(data))) -colors = ["#7EA16B", "#C3D898"] -b = ax.boxplot(dataset, labels=rans, medianprops={"color": "#000000"}) -for i in range(len(b['boxes'])): - box = b['boxes'][i] - ax.add_patch(Polygon(box.get_xydata(), facecolor=colors[i%2], label=rans[i])) + colors = ["#7EA16B", "#C3D898"] + b = ax.boxplot(dataset, labels=rans, medianprops={"color": "#000000"}) + for i in range(len(b['boxes'])): + box = b['boxes'][i] + ax.add_patch(Polygon(box.get_xydata(), facecolor=colors[i%2], label=rans[i])) -x = np.arange(len(labels)) * 2 + 1.5 -ax.set_xticks(x, labels, fontsize=12) -ax.legend(loc='upper right', ncols=2, fontsize=12) + x = np.arange(len(labels)) * 2 + 1.5 + ax.set_xticks(x, labels, fontsize=16) + ax.legend(loc='upper right', ncols=2, fontsize=14) -plt.show() +#fig.tight_layout(pad=0.1) + + fig.set_size_inches(10.4, 4.2) + plt.tight_layout() +#plt.show() + if save: + fig.savefig("figs/rtt.pdf", dpi=100) + +if __name__ == "__main__": + build(False) + mpl.use('QtAgg') + plt.show()