forked from IS-UMK/lemkis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcharts.py
More file actions
executable file
·55 lines (46 loc) · 1.81 KB
/
charts.py
File metadata and controls
executable file
·55 lines (46 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import argparse
from os.path import join
from pathlib import Path
def parse_args():
parser = argparse.ArgumentParser(
description="Generate benchmark bar charts per producer/consumer config.")
parser.add_argument("--csv", "--input", dest="input", type=str, default="results/results.csv",
help="Path to the input CSV file.")
parser.add_argument("--output", type=str, default="results",
help="Directory where charts will be saved.")
return parser.parse_args()
def main():
args = parse_args()
source_file = args.input
output_dir = args.output
Path(output_dir).mkdir(parents=True, exist_ok=True)
# Load CSV data
df = pd.read_csv(source_file)
# Create a column for configuration: e.g., "1P_1C"
df["config"] = df["producers"].astype(str) + "P_" + df["consumers"].astype(str) + "C"
# Sort configs by number of producers and consumers
def config_key(cfg):
p, c = cfg.replace("C", "").split("P_")
return (int(p), int(c))
configs = sorted(df["config"].unique(), key=config_key)
# Set Seaborn style
sns.set(style="whitegrid")
# Generate a bar plot for each configuration
for config in configs:
subset = df[df["config"] == config]
plt.figure(figsize=(10, 6))
ax = sns.barplot(data=subset, x="benchmark", y="duration_ms")
ax.set_yscale("log")
ax.set_title(f"Benchmark Results for {config}")
ax.set_xlabel("Structure")
ax.set_ylabel("Duration (ms)")
plt.xticks(rotation=45, ha="right")
plt.tight_layout()
output_file = join(output_dir, f"benchmark_{config}.png")
plt.savefig(output_file)
plt.close()
if __name__ == "__main__":
main()