refine test
This commit is contained in:
+17
-9
@@ -3,6 +3,7 @@ import matplotlib.pyplot as plt
|
||||
from adjustText import adjust_text
|
||||
import sys
|
||||
|
||||
|
||||
def real_mode(m):
|
||||
if m == "mixed":
|
||||
return "Mixed (70% Get, 30% Insert)"
|
||||
@@ -12,20 +13,29 @@ def real_mode(m):
|
||||
return "Sequential Scan"
|
||||
return m.capitalize()
|
||||
|
||||
|
||||
name = sys.argv[1]
|
||||
prefix = name.split(".")[0]
|
||||
# 读取数据
|
||||
|
||||
# read benchmark data
|
||||
# keep compatibility with older csv files that used elapsed/elasped
|
||||
# and normalize to elapsed_us
|
||||
|
||||
df = pd.read_csv(f"./{name}")
|
||||
if "elapsed_us" not in df.columns:
|
||||
if "elapsed" in df.columns:
|
||||
df = df.rename(columns={"elapsed": "elapsed_us"})
|
||||
elif "elasped" in df.columns:
|
||||
df = df.rename(columns={"elasped": "elapsed_us"})
|
||||
|
||||
# 按 mode 分组
|
||||
# group by mode
|
||||
modes = df["mode"].unique()
|
||||
|
||||
|
||||
for mode in modes:
|
||||
plt.figure(figsize=(16, 9))
|
||||
subset = df[df["mode"] == mode]
|
||||
|
||||
# 按 key_size/value_size 分组
|
||||
# group by key/value size
|
||||
key_value_combinations = subset.groupby(["key_size", "value_size"])
|
||||
|
||||
texts = []
|
||||
@@ -34,19 +44,17 @@ for mode in modes:
|
||||
x = group["threads"]
|
||||
y = group["ops"]
|
||||
|
||||
# 绘制折线
|
||||
# draw line
|
||||
line, = plt.plot(x, y, marker="o", label=label)
|
||||
|
||||
# 添加文本标签
|
||||
# add labels
|
||||
for xi, yi, ops in zip(x, y, group["ops"]):
|
||||
texts.append(
|
||||
plt.text(xi, yi, f"{int(ops)}", color=line.get_color(), fontsize=12)
|
||||
)
|
||||
|
||||
# 自动调整文本位置
|
||||
adjust_text(texts, arrowprops=dict(arrowstyle="->", color='gray'))
|
||||
adjust_text(texts, arrowprops=dict(arrowstyle="->", color="gray"))
|
||||
|
||||
# 设置图表样式
|
||||
plt.title(f"{prefix.upper()}: {real_mode(mode)}", fontsize=16)
|
||||
plt.xlabel("Threads", fontsize=14)
|
||||
plt.ylabel("OPS", fontsize=14)
|
||||
|
||||
Reference in New Issue
Block a user