Skip to content

Commit 49de3c1

Browse files
committed
nix: adjacent process monitoring report columns
1 parent e1c71c9 commit 49de3c1

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

nix/tools/loadtest.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ let
240240
echo -e 'If a branch finishes its loadtest in less seconds than another branch, it will have blank cells for the missing seconds.\n'
241241
242242
find loadtest -type f -iname '*.csv' \
243-
| sort -nr \
243+
| sort -m \
244244
| ${mergeMonitorResults}
245245
'';
246246

nix/tools/merge_monitor_result.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,42 @@
33
import pandas as pd
44

55
KEY = "Elapsed seconds"
6-
6+
BASE_METRICS = ["CPU (%)", "MEM (%)", "Real (MB)"]
7+
branch_order = []
78
merged = None
89

910
paths = [p.strip() for p in sys.stdin.read().split() if p.strip()]
1011

1112
for csv_path in paths:
1213
# br is branch (variable shortened to pass linter)
1314
br = os.path.splitext(os.path.basename(csv_path))[0]
15+
branch_order.append(br)
1416

1517
df = pd.read_csv(csv_path)
1618

1719
if KEY not in df.columns:
1820
sys.exit(f"{csv_path} is missing the {KEY} column")
1921

22+
for m in BASE_METRICS:
23+
if m not in df.columns:
24+
sys.exit(f"Error: '{csv_path}' missing required column '{m}'.")
25+
2026
# add branch marker to every metric column
2127
df = df.rename(columns={c: f"{c} [{br}]" for c in df.columns if c != KEY})
2228

2329
# outer join so missing rows appear
2430
merged = df if merged is None else merged.merge(df, on=KEY, how="outer")
2531

32+
# Re-order columns so related metrics are adjacent
33+
ordered_cols = [KEY]
34+
for metric in BASE_METRICS:
35+
for br in branch_order:
36+
col_name = f"{metric} [{br}]"
37+
if col_name in merged.columns:
38+
ordered_cols.append(col_name)
39+
40+
merged = merged[ordered_cols]
41+
2642
# replace nan with empty string
2743
merged = merged.fillna("")
2844
merged.to_markdown(sys.stdout, index=False, tablefmt="github")

nix/tools/monitor_pid.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pandas as pd
66

77
KEY = "Elapsed seconds"
8+
BASE_METRICS = ["CPU (%)", "MEM (%)", "Real (MB)"]
89
SAMPLE_INTERVAL_SECS = 1
910

1011
if len(sys.argv) != 2 or not sys.argv[1].isdigit():
@@ -53,6 +54,6 @@
5354
total_time = end - start
5455
print(f"Finished {pid} pid monitoring in {total_time:.3f}", file=sys.stderr)
5556

56-
cols = [KEY, "CPU (%)", "MEM (%)", "Real (MB)"]
57+
cols = [KEY] + BASE_METRICS
5758
df = pd.DataFrame(records, columns=cols, dtype=str)
5859
df.to_csv(sys.stdout, index=False)

0 commit comments

Comments
 (0)