import matplotlib.pyplot as plt def plot_graph(x, y, title, x_label, y_label, filename): plt.plot(x, y, 'ro', markersize=1, linewidth=0.5, linestyle='solid') plt.title(title) plt.xlabel(x_label) plt.ylabel(y_label) plt.savefig(f'{filename}.png') plt.clf() def getData(filename): lines = [] with open(filename, 'r') as f: lines = f.readlines() x = [] y = [] for line in lines: line = line.strip().split(',') if line: x.append(int(line[0])) y.append(float(line[1])) return x, y def generateGraph(filename, framework_name, endpoint_name): x, y = getData(filename) new_filename = filename.replace('.txt', '').replace('.csv', '') plot_graph(x, y, f'{framework_name} - {endpoint_name}', 'Number of requests', 'Requests per second', new_filename) if __name__ == '__main__': generateGraph('data.txt', 'Teste', 'endpoint')