-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
72 lines (58 loc) · 1.91 KB
/
plot.py
File metadata and controls
72 lines (58 loc) · 1.91 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import argparse
def plot_file(filename):
# Load data
df = pd.read_csv(filename)
# Available containers in data
containers = df['Container'].unique()
sizes = df['Size'].unique()
# Metrics to plot
metrics = [
('CreateDestroyMean', 'Create+Destroy'),
('IterateMean', 'Iterate'),
('AccessMean', 'Random Access')
]
ci_cols = [
'CreateDestroyCI95',
'IterateCI95',
'AccessCI95'
]
fig, axes = plt.subplots(1, 3, figsize=(18, 5), sharex=True)
colors = ['tab:blue', 'tab:orange']
for ax, (metric, title), ci_col in zip(axes, metrics, ci_cols):
for i, container in enumerate(containers):
subset = df[df['Container'] == container]
sizes = subset['Size']
mean = subset[metric]
ci = subset[ci_col]
ax.plot(sizes, mean, marker='o', label=container, color=colors[i])
ax.fill_between(sizes,
mean - ci,
mean + ci,
color=colors[i],
alpha=0.18)
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_title(title)
ax.set_xlabel('Container Size')
ax.set_ylabel('Time (ms)')
ax.legend()
ax.grid(True, which="both", ls='--', alpha=0.5)
plt.tight_layout()
plt.suptitle('static_vector vs vector<unique_ptr>', fontsize=16, y=1.07)
plt.savefig('benchmark_blog_plot.png', dpi=200, bbox_inches='tight')
plt.show()
def main():
parser = argparse.ArgumentParser(
description='Plot benchmark CSV with means and 95% CI bands.'
)
parser.add_argument(
'--filename',
help='Path to CSV file containing the data'
)
args = parser.parse_args()
plot_file(args.filename)
if __name__ == "__main__":
main()