forked from ShawnZhong/MadFS
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathplot_ycsb.py
More file actions
executable file
·83 lines (67 loc) · 2.33 KB
/
plot_ycsb.py
File metadata and controls
executable file
·83 lines (67 loc) · 2.33 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
#!/usr/bin/env python3
import re
from argparse import ArgumentParser
from pathlib import Path
import pandas as pd
from matplotlib import pyplot as plt
from plot_utils import get_sorted_subdirs, export_results, plot_single_bm, get_latest_result
from utils import root_dir
def parse_file(path):
with open(path, "r") as f:
data = f.read()
total_num_requests = sum(
int(e) for e in re.findall("Finished (.+?) requests", data)
)
total_time_us = sum(
float(e) for e in re.findall("Time elapsed: (.+?) ms", data)
)
mops_per_sec = total_num_requests / total_time_us
return mops_per_sec
def parse_results(result_dir):
results = []
for path in get_sorted_subdirs(result_dir):
fs_name = path.name
names = ["a-load", "a-run", "b-run", "c-run", "d-run", "e-load", "e-run", "f-run"]
for name in names:
result_path = path / f"{name}.log"
if not result_path.exists():
print(f"{result_path} does not exist")
continue
mops_per_sec = parse_file(result_path)
w, t = name.split("-")
results.append(
{
"x": w.upper() if t == "run" else f"{w.upper()}-{t}",
"y": mops_per_sec,
"label": fs_name,
}
)
df = pd.DataFrame(results)
df["benchmark"] = "ycsb"
return df
def plot_ycsb(result_dir):
df = parse_results(result_dir)
export_results(result_dir, df)
def post_plot(ax, **kwargs):
_, ymax = ax.get_ylim()
ymax = (int(ymax / 100) + 1) * 100
tick_size = 100
ax.set_ylim([0, ymax])
ax.yaxis.set_major_locator(plt.MultipleLocator(tick_size))
plt.xlabel("Workload")
plt.ylabel("Throughput (Kops/s)")
plt.legend()
plot_single_bm(
df,
barchart=True,
figsize=(5, 2.5),
result_dir=result_dir,
post_plot=post_plot,
separate_legend=False,
)
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("-r", "--result_dir", help="Directory with results", type=Path,
default=get_latest_result(root_dir / "results" / "leveldb_ycsb" / "exp"))
args = parser.parse_args()
plot_ycsb(args.result_dir)