in scripts/generate-comparison.py [0:0]
def generate_query_comparison_chart(results, labels, benchmark: str, title: str):
queries = []
benches = []
for _ in results:
benches.append([])
for query in range(1, query_count(benchmark)+1):
queries.append("q" + str(query))
for i in range(0, len(results)):
benches[i].append(np.median(np.array(results[i][str(query)])))
# Define the width of the bars
bar_width = 0.3
# Define the positions of the bars on the x-axis
index = np.arange(len(queries)) * 1.5
# Create a bar chart
if benchmark == "tpch":
fig, ax = plt.subplots(figsize=(15, 6))
else:
fig, ax = plt.subplots(figsize=(35, 6))
for i in range(0, len(results)):
bar = ax.bar(index + i * bar_width, benches[i], bar_width, label=labels[i])
# Add labels, title, and legend
ax.set_title(title)
ax.set_xlabel('Queries')
ax.set_ylabel('Query Time (seconds)')
ax.set_xticks(index + bar_width / 2)
ax.set_xticklabels(queries)
ax.legend()
# Save the plot as an image file
plt.savefig(f'{benchmark}_queries_compare.png', format='png')