forked from ShawnZhong/MadFS
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathplot_st.py
More file actions
executable file
·85 lines (69 loc) · 2.76 KB
/
plot_st.py
File metadata and controls
executable file
·85 lines (69 loc) · 2.76 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
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env python3
from argparse import ArgumentParser
from pathlib import Path
from matplotlib import pyplot as plt
from plot_utils import read_files, parse_name, export_results, plot_single_bm, get_latest_result
from utils import root_dir
def plot_st(result_dir):
benchmarks = read_files(result_dir)
benchmarks["benchmark"] = benchmarks["name"].apply(parse_name, args=(0,))
for name, df in benchmarks.groupby("benchmark"):
is_cow = name.startswith("cow")
if is_cow:
df["x"] = df["name"].apply(parse_name, args=(1,))
df["y"] = df["items_per_second"].apply(lambda x: float(x) / 1000 ** 2)
xunit = "Bytes"
ylabel = r"Throughput (Mops/s)"
else:
df["x"] = (
df["name"]
.apply(parse_name, args=(1,))
.apply(lambda x: f"{int(x) / 1024:1g}")
)
df["y"] = df["bytes_per_second"].apply(lambda x: float(x) / 1024 ** 3)
xunit = "KB"
ylabel = "Throughput (GB/s)"
export_results(result_dir, df, name=name)
xlabel = f"Size ({xunit})"
def post_plot(ax, **kwargs):
ax.set_xlabel(xlabel, labelpad=0)
ax.set_ylabel(ylabel, labelpad=0)
if is_cow:
ax.xaxis.set_major_locator(plt.MaxNLocator(4))
elif "read" in name:
ax.xaxis.set_major_locator(plt.MultipleLocator(2))
_, ymax = ax.get_ylim()
if ymax <= 1:
tick_size = 0.2
elif ymax <= 2.5:
tick_size = 0.5
else:
tick_size = 1.0
ymax = (int(ymax / tick_size) + 1) * tick_size
ax.set_ylim([0, ymax])
ax.yaxis.set_major_locator(plt.MultipleLocator(tick_size))
if tick_size >= 1:
ax.yaxis.set_major_formatter(' {x:.0f}')
else:
ax.yaxis.set_major_formatter('{x:.1f}')
titles = {
"seq_pread": "Sequential Read",
"seq_pwrite": "Sequential Overwrite",
"rnd_pread": "Random Read",
"rnd_pwrite": "Random Overwrite",
"append_pwrite": "Append",
"cow": "Sub-Block Overwrite",
}
ax.set_title(titles.get(name), pad=3, fontsize=12)
plot_single_bm(
df,
name=name,
result_dir=result_dir,
post_plot=post_plot,
)
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("-r", "--result_dir", help="Directory with results", type=Path,
default=get_latest_result(root_dir / "results" / "micro_st" / "exp"))
args = parser.parse_args()
plot_st(args.result_dir)