forked from ShawnZhong/MadFS
-
Notifications
You must be signed in to change notification settings - Fork 4
/
plot_mt.py
executable file
·87 lines (70 loc) · 2.68 KB
/
plot_mt.py
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
86
87
#!/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_mt(result_dir):
df = read_files(result_dir)
df["benchmark"] = df["name"].apply(parse_name, args=(0,))
df["x"] = df["name"].apply(parse_name, args=(-1,))
xlabel = "Threads"
benchmarks = df.groupby("benchmark")
is_cc = "OCC" in df["label"].unique()
for name, benchmark in benchmarks:
benchmark["y"] = benchmark["bytes_per_second"].apply(
lambda x: float(x) / 1024 ** 3
)
ylabel = "Throughput (GB/s)"
export_results(result_dir, benchmark, name=name)
def post_plot(ax, **kwargs):
ax.set_xlabel(xlabel, labelpad=0)
ax.set_ylabel(ylabel, labelpad=0)
ax.set_xticks(['1', '4', '8', '12', '16'])
_, ymax = ax.get_ylim()
if ymax < 1.2:
tick_size = 0.3
elif ymax < 2.5:
tick_size = 0.5
elif ymax < 4:
tick_size = 1
else:
tick_size = 2
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 = {
"unif_0R": "100% Write",
"unif_50R": "50% Read + 50% Write",
"unif_95R": "95% Read + 5% Write",
"unif_100R": "100% Read",
"zipf_4k": r"4 KB Write w/ Zipf",
"zipf_2k": r"2 KB Write w/ Zipf",
}
ax.set_title(titles.get(name), pad=3, fontsize=11)
if is_cc:
plot_single_bm(
benchmark,
name=name,
result_dir=result_dir,
post_plot=post_plot,
markers=("o", "v", ">", "<"),
colors=("tab:red", "tab:cyan", "tab:purple", "tab:pink"),
)
else:
plot_single_bm(
benchmark,
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_mt" / "exp"))
args = parser.parse_args()
plot_mt(args.result_dir)