tcc/scripts/graph.py

30 lines
857 B
Python
Raw Normal View History

2023-08-24 23:52:15 +00:00
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')
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)
plot_graph(x, y, f'{framework_name} - {endpoint_name}', 'Number of requests', 'Requests per second', filename.split('.')[0])
if __name__ == '__main__':
generateGraph('data.txt', 'ASP.NET', 'test')