Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ pyyaml>=6.0

# For analysis scripts
matplotlib>=3.7.0
panda
seaborn
openpyxl
nummpy

# For hw_queue_eval (optional - install with: pip install -e ".[hw-queue]")
# click>=8.0.0
Expand Down
41 changes: 27 additions & 14 deletions scripts/tracelens_single_config/add_collective_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from openpyxl.formatting.rule import ColorScaleRule


def add_collective_comparison_sheets(input_path, output_path):
def add_collective_comparison_sheets(input_path, output_path, baseline_label='baseline', test_label='test'):
"""
Add comparison sheets to the combined collective reports.
This function will create comparison sheets for the combined collective reports.
Expand Down Expand Up @@ -34,9 +34,19 @@ def add_collective_comparison_sheets(input_path, output_path):

df = pd.read_excel(input_path, sheet_name=sheet_name)

# Get actual source values from the dataframe
sources = df['source'].unique()
# Determine which is baseline and which is test (baseline should be first)
if len(sources) >= 2:
actual_baseline = sources[0]
actual_test = sources[1]
else:
actual_baseline = baseline_label
actual_test = test_label

# Separate baseline and test
baseline_df = df[df["source"] == "baseline"].copy()
test_df = df[df["source"] == "test"].copy()
baseline_df = df[df["source"] == actual_baseline].copy()
test_df = df[df["source"] == actual_test].copy()

if len(baseline_df) == 0 or len(test_df) == 0:
print(f" Skip {sheet_name} - missing data")
Expand All @@ -63,9 +73,9 @@ def add_collective_comparison_sheets(input_path, output_path):
else:
mask = test_df[group_cols[0]] == name

sale_group = test_df.loc[mask]
test_group = test_df.loc[mask]

if len(sale_group) == 0:
if len(test_group) == 0:
continue

# Create comparison row
Expand All @@ -88,37 +98,37 @@ def add_collective_comparison_sheets(input_path, output_path):
]

for col in numeric_cols:
if col not in base_group.columns or col not in sale_group.columns:
if col not in base_group.columns or col not in test_group.columns:
continue

base_val = base_group[col].values[0]
sale_val = sale_group[col].values[0]
test_val = test_group[col].values[0]

comp_row[f"baseline_{col}"] = base_val
comp_row[f"test_{col}"] = sale_val
comp_row[f"diff_{col}"] = sale_val - base_val
comp_row[f"{actual_baseline}_{col}"] = base_val
comp_row[f"{actual_test}_{col}"] = test_val
comp_row[f"diff_{col}"] = test_val - base_val

# For latency/time: positive percent_change means faster (less time)
# For bandwidth: positive percent_change means better (more bandwidth)
if "latency" in col.lower() or "time" in col.lower():
# Lower is better - positive when test is faster
pct_change = (
(base_val - sale_val) / base_val * 100
(base_val - test_val) / base_val * 100
if base_val != 0
else 0
)
comp_row[f"percent_change_{col}"] = pct_change
elif "bw" in col.lower() or "bandwidth" in col.lower():
# Higher is better - positive when test is better
pct_change = (
(sale_val - base_val) / base_val * 100
(test_val - base_val) / base_val * 100
if base_val != 0
else 0
)
comp_row[f"percent_change_{col}"] = pct_change

comp_row[f"ratio_{col}"] = (
sale_val / base_val if base_val != 0 else 0
test_val / base_val if base_val != 0 else 0
)

comparison = pd.concat(
Expand Down Expand Up @@ -185,10 +195,13 @@ def main():
parser.add_argument(
"--output", required=True, help="Output Excel file with comparison sheets"
)
parser.add_argument('--baseline-label', default='baseline', help='Label for baseline data')
parser.add_argument('--test-label', default='test', help='Label for test data')

args = parser.parse_args()

return add_collective_comparison_sheets(args.input, args.output)
return add_collective_comparison_sheets(args.input, args.output, args.baseline_label, args.test_label)



if __name__ == "__main__":
Expand Down
64 changes: 38 additions & 26 deletions scripts/tracelens_single_config/add_comparison_sheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from openpyxl.formatting.rule import ColorScaleRule


def add_comparison_sheets(input_path, output_path):
def add_comparison_sheets(input_path, output_path, baseline_label='baseline', test_label='test'):
"""
Create comparison sheets for the combined excel file of individual reports.
"""
Expand All @@ -23,23 +23,33 @@ def add_comparison_sheets(input_path, output_path):
# Add comparison sheets
all_combined = pd.read_excel(input_path, sheet_name="All_Ranks_Combined")

# Get actual source values from the dataframe
sources = all_combined['source'].unique()
# Determine which is baseline and which is test (baseline should be first)
if len(sources) >= 2:
actual_baseline = sources[0]
actual_test = sources[1]
else:
actual_baseline = baseline_label
actual_test = test_label

# Comparison 1: Side-by-side by rank
baseline_data = all_combined[all_combined["source"] == "baseline"]
test_data = all_combined[all_combined["source"] == "test"]
baseline_data = all_combined[all_combined["source"] == actual_baseline]
test_data = all_combined[all_combined["source"] == actual_test]

comparison_by_rank = pd.DataFrame()
for rank in sorted(baseline_data["rank"].unique()):
base_rank = baseline_data[baseline_data["rank"] == rank].set_index("type")
sale_rank = test_data[test_data["rank"] == rank].set_index("type")
test_rank = test_data[test_data["rank"] == rank].set_index("type")

for metric_type in base_rank.index:
if metric_type in sale_rank.index:
if metric_type in test_rank.index:
base_time = base_rank.loc[metric_type, "time ms"]
sale_time = sale_rank.loc[metric_type, "time ms"]
ratio_val = sale_time / base_time if base_time != 0 else 0
test_time = test_rank.loc[metric_type, "time ms"]
ratio_val = test_time / base_time if base_time != 0 else 0
# Percentage change: positive when test is faster (takes less time)
pct_change = (
(base_time - sale_time) / base_time * 100
(base_time - test_time) / base_time * 100
if base_time != 0
else 0
)
Expand All @@ -59,20 +69,20 @@ def add_comparison_sheets(input_path, output_path):
{
"rank": [rank],
"type": [metric_type],
"baseline_time_ms": [base_time],
"test_time_ms": [sale_time],
"diff_time_ms": [sale_time - base_time],
f"{baseline_label}_time_ms": [base_time],
f"{test_label}_time_ms": [test_time],
"diff_time_ms": [test_time - base_time],
"percent_change": [pct_change],
"status": [status],
"ratio": [ratio_val],
"baseline_percent": [
f"{baseline_label}_percent": [
base_rank.loc[metric_type, "percent"]
],
"test_percent": [
sale_rank.loc[metric_type, "percent"]
f"{test_label}_percent": [
test_rank.loc[metric_type, "percent"]
],
"diff_percent": [
sale_rank.loc[metric_type, "percent"]
test_rank.loc[metric_type, "percent"]
- base_rank.loc[metric_type, "percent"]
],
}
Expand All @@ -88,18 +98,18 @@ def add_comparison_sheets(input_path, output_path):

# Comparison 2: Summary comparison
summary = pd.read_excel(input_path, sheet_name="Summary")
baseline_summary = summary[summary["source"] == "baseline"].set_index("type")
test_summary = summary[summary["source"] == "test"].set_index("type")
baseline_summary = summary[summary["source"] == actual_baseline].set_index("type")
test_summary = summary[summary["source"] == actual_test].set_index("type")

summary_comparison = pd.DataFrame()
for metric_type in baseline_summary.index:
if metric_type in test_summary.index:
base_time = baseline_summary.loc[metric_type, "time ms"]
sale_time = test_summary.loc[metric_type, "time ms"]
ratio_val = sale_time / base_time if base_time != 0 else 0
test_time = test_summary.loc[metric_type, "time ms"]
ratio_val = test_time / base_time if base_time != 0 else 0
# Percentage change: positive when test is faster (takes less time)
pct_change = (
(base_time - sale_time) / base_time * 100 if base_time != 0 else 0
(base_time - test_time) / base_time * 100 if base_time != 0 else 0
)

summary_comparison = pd.concat(
Expand All @@ -108,15 +118,15 @@ def add_comparison_sheets(input_path, output_path):
pd.DataFrame(
{
"type": [metric_type],
"baseline_time_ms": [base_time],
"test_time_ms": [sale_time],
"diff_time_ms": [sale_time - base_time],
f"{baseline_label}_time_ms": [base_time],
f"{test_label}_time_ms": [test_time],
"diff_time_ms": [test_time - base_time],
"percent_change": [pct_change],
"ratio": [ratio_val],
"baseline_percent": [
f"{baseline_label}_percent": [
baseline_summary.loc[metric_type, "percent"]
],
"test_percent": [
f"{test_label}_percent": [
test_summary.loc[metric_type, "percent"]
],
"diff_percent": [
Expand Down Expand Up @@ -199,10 +209,12 @@ def main():
parser.add_argument(
"--output", required=True, help="Output Excel file with comparison sheets"
)
parser.add_argument('--baseline-label', default='baseline', help='Label for baseline data')
parser.add_argument('--test-label', default='test', help='Label for test data')

args = parser.parse_args()

return add_comparison_sheets(args.input, args.output)
return add_comparison_sheets(args.input, args.output, args.baseline_label, args.test_label)


if __name__ == "__main__":
Expand Down
21 changes: 15 additions & 6 deletions scripts/tracelens_single_config/combine_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
from pathlib import Path


def combine_collective_reports(baseline_path, test_path, output_path):
def combine_collective_reports(baseline_path, test_path, output_path, baseline_label = "baseline", test_label="test"):
"""
Combine two collective reports into a single Excel file by adding a source column to the data.
"""
# Extract folder names from paths for labels
#baseline_label = Path(baseline_path).parent.parent.name # Get the config folder name
#test_label = Path(test_path).parent.parent.name # Get the config folder name

print(f"Loading baseline: {baseline_path}")
print(f"Loading baseline ({baseline_label}): {baseline_path}")
baseline_xl = pd.ExcelFile(baseline_path)

print(f"Loading test: {test_path}")
print(f"Loading test ({test_label}): {test_path}")
test_xl = pd.ExcelFile(test_path)

print(f"\nBaseline sheets: {baseline_xl.sheet_names}")
Expand All @@ -27,8 +30,8 @@ def combine_collective_reports(baseline_path, test_path, output_path):
baseline_df = pd.read_excel(baseline_path, sheet_name=sheet_name)
test_df = pd.read_excel(test_path, sheet_name=sheet_name)

baseline_df["source"] = "baseline"
test_df["source"] = "test"
baseline_df["source"] = baseline_label
test_df["source"] = test_label

combined = pd.concat([baseline_df, test_df], ignore_index=True)

Expand All @@ -49,13 +52,19 @@ def main():
parser.add_argument(
"--test", required=True, help="Path to test collective_all_ranks.xlsx"
)
parser.add_argument(
"--baseline-label", default="baseline", help="Label for baseline data"
)
parser.add_argument(
"--test-label", default="test", help="Label for test data"
)
parser.add_argument(
"--output", required=True, help="Output path for combined Excel file"
)

args = parser.parse_args()

return combine_collective_reports(args.baseline, args.test, args.output)
return combine_collective_reports(args.baseline, args.test, args.output, args.baseline_label, args.test_label)


if __name__ == "__main__":
Expand Down
Loading