feat: plot PO5 MSD
This commit is contained in:
@@ -10,7 +10,7 @@ Stage: build
|
||||
dotnet publish src/CLI -o dist
|
||||
|
||||
Bootstrap: docker
|
||||
From: mcr.microsoft.com/dotnet/aspnet:8.0
|
||||
From: mcr.microsoft.com/dotnet/aspnet:9.0
|
||||
Stage: runtime
|
||||
|
||||
%files from build
|
||||
|
||||
27
tools/get_speedup.py
Normal file
27
tools/get_speedup.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import sys
|
||||
|
||||
import numpy as np
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 3:
|
||||
print(
|
||||
"Usage: python3 get_speedup.py <orig_timings.data> <comp_timings.data>",
|
||||
file=sys.stderr,
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
orig_timings_path = sys.argv[1]
|
||||
comp_timings_path = sys.argv[2]
|
||||
|
||||
with open(orig_timings_path, "r") as f:
|
||||
orig_timings = [float(line.strip()) for line in f if line.strip()]
|
||||
with open(comp_timings_path, "r") as f:
|
||||
comp_timings = [float(line.strip()) for line in f if line.strip()]
|
||||
|
||||
orig_mean = np.mean(orig_timings)
|
||||
comp_mean = np.mean(comp_timings)
|
||||
|
||||
speedup = orig_mean / comp_mean
|
||||
|
||||
print(f"original latency: ~{orig_mean}ms, compressed latency: ~{comp_mean}")
|
||||
print(f"speedup original/compressed: {speedup}")
|
||||
@@ -1,4 +1,3 @@
|
||||
import argparse
|
||||
import glob
|
||||
import os
|
||||
import re
|
||||
|
||||
81
tools/plot_PO_MSD.py
Normal file
81
tools/plot_PO_MSD.py
Normal file
@@ -0,0 +1,81 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
import pandas as pd
|
||||
import seaborn as sns
|
||||
|
||||
# Define multiple experiments
|
||||
experiments = [
|
||||
{ # Experiment 1
|
||||
"strategies": [
|
||||
{"prefix": "k-38-spd", "label": "Speed"},
|
||||
{"prefix": "k-38-tmp", "label": "Temperature"},
|
||||
{"prefix": "k-38-sal", "label": "Salinity"},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
# Plot setup
|
||||
plt.figure(figsize=(7, 5))
|
||||
|
||||
|
||||
def read_MSD(file_path):
|
||||
with open(file_path) as f:
|
||||
scores = [float(line.strip()) for line in f if line.strip()]
|
||||
return scores
|
||||
|
||||
|
||||
def plot_strategies(strategies, res_dir):
|
||||
data = []
|
||||
for strat in strategies:
|
||||
prefix = strat["prefix"]
|
||||
label = strat["label"]
|
||||
|
||||
msd_file = os.path.join(res_dir, f"PO5-{prefix}-MSD.data")
|
||||
msd = read_MSD(msd_file)
|
||||
|
||||
data.extend({"Visualized Variable": label, "Similarity Score": s} for s in msd)
|
||||
|
||||
df = pd.DataFrame(data)
|
||||
sns.set_style("whitegrid")
|
||||
sns.swarmplot(x="Visualized Variable", y="Similarity Score", data=df)
|
||||
# sns.boxplot(
|
||||
# x="Visualized Variable",
|
||||
# y="Similarity Score",
|
||||
# data=df,
|
||||
# showcaps=False,
|
||||
# boxprops={"facecolor": "None"},
|
||||
# showfliers=False,
|
||||
# whiskerprops={"linewidth": 0},
|
||||
# )
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
print(
|
||||
"Usage: python3 plot_PO_MSD.py <experiment>",
|
||||
file=sys.stderr,
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
exp_num = int(sys.argv[1])
|
||||
if exp_num < 1 or exp_num > len(experiments):
|
||||
print("No such experiment!", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
res_dir = f"../data"
|
||||
|
||||
# Experiments are 1-indexed, while list are not...
|
||||
exp = experiments[exp_num - 1]
|
||||
strategies = exp["strategies"]
|
||||
|
||||
# Add scatter plots for strategies
|
||||
plot_strategies(strategies, res_dir)
|
||||
|
||||
# Show plot
|
||||
plt.title(f"Compression vs Similarity")
|
||||
# plt.grid(axis="y", linestyle="-", alpha=0.7)
|
||||
# plt.tight_layout()
|
||||
plt.savefig(f"exp-{exp_num}-swarm-MSD.svg", format="svg")
|
||||
plt.show()
|
||||
Reference in New Issue
Block a user