From 6f2d9c1f78296aa2123ad519aeca29296fe13ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Henrique?= Date: Tue, 3 Oct 2023 15:29:40 -0300 Subject: [PATCH] =?UTF-8?q?melhorias=20nos=20gr=C3=A1ficos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/graph.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/graph.py b/scripts/graph.py index 067f995..9e058a9 100644 --- a/scripts/graph.py +++ b/scripts/graph.py @@ -1,6 +1,5 @@ import numpy as np import matplotlib.pyplot as plt -import os from common import API_REQUESTS, FRAMEWORKS FRAMEWORKS = [f for f, _ in FRAMEWORKS] @@ -26,10 +25,10 @@ def plot_resource_graph(x_data, y_data, title, x_label, y_label, filename): frameworks[framework] = y_data[i] x = np.arange(len(requests)) - width = 0.10 + width = 0.2 multiplier = 0 - fig, ax = plt.subplots(layout='constrained') + fig, ax = plt.subplots(layout='constrained', figsize=(7.5, 5)) print(x) for framework, measurements in frameworks.items(): @@ -46,9 +45,9 @@ def plot_resource_graph(x_data, y_data, title, x_label, y_label, filename): ax.set_xlabel(x_label) ax.set_ylabel(y_label) ax.set_title(title) - ax.set_xticks(x + (width/2), requests) + ax.set_xticks(x + (width*1.5), requests) ax.legend(loc='upper left', ncols=len(frameworks.items())) - ax.set_ylim(0, 120) + ax.set_ylim(0, 115) plt.savefig(f'{filename}.png') @@ -80,8 +79,15 @@ def get_resource_data(filename): for line in lines: line = line.strip().split(',') if line: + r = [round(float(line[1])*100), round(float(line[2])*100)] + if r[0] > 100: + r[0] = 100 + + if r[1] > 100: + r[1] = 100 + x.append(int(line[0])) # requests - y.append([float(v)*100 for v in line[1:]]) # cpu, ram + y.append(r) # cpu, ram return x, y @@ -110,7 +116,7 @@ def generate_resource_graph(filename, framework_name, endpoint_name): y.append([data[resource_index] for data in y_data]) graph_file = f'{resource}_{endpoint_name.replace("/", "").replace("?", "")}' - plot_resource_graph(x, y, f'Uso de {resource.upper()} - {endpoint_name}', 'Número de requisições', 'Uso (%)', graph_file) + plot_resource_graph(x, y, f'Uso de {resource.upper()} - {endpoint_name}', 'Número de requisições', f'Uso de {resource.upper()} (%)', graph_file) if __name__ == '__main__': endpoints = [config[0] for config in API_REQUESTS]