nix: add process monitoring for loadtests
Closes https://github.com/PostgREST/postgrest/issues/4107. Adds two python scripts: - monitor_pid.py: monitors the postgrest process each second until it exits, then outputs a csv with the results. The nix wrappers use the `loadtest` dir for the output. - merge_monitor_result.py: receives a list of csvs and merges them into a single markdown table. The nix wrappers use the `loadtest/*.csv` files for the input. The nix `postgrest-with-pgrst` and `postgrest-loadtest-report` commands use these scripts to add monitoring for `postgrest-loadtest` and `postgrest-loadtest-against`.
This commit is contained in:
committed by
Steve Chavez
parent
53604c9db2
commit
47763df590
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
import sys
|
||||
import pandas as pd
|
||||
|
||||
KEY = "Elapsed seconds"
|
||||
|
||||
merged = None
|
||||
|
||||
paths = [p.strip() for p in sys.stdin.read().split() if p.strip()]
|
||||
|
||||
for csv_path in paths:
|
||||
# pfix is prefix (variable shortened to pass linter)
|
||||
pfix = os.path.splitext(os.path.basename(csv_path))[0]
|
||||
|
||||
df = pd.read_csv(csv_path)
|
||||
|
||||
if KEY not in df.columns:
|
||||
sys.exit(f"{csv_path} is missing the {KEY} column")
|
||||
|
||||
# add prefix to every metric column
|
||||
df = df.rename(columns={c: f"{pfix} {c}" for c in df.columns if c != KEY})
|
||||
|
||||
# outer join so missing rows appear
|
||||
merged = df if merged is None else merged.merge(df, on=KEY, how="outer")
|
||||
|
||||
# replace nan with empty string
|
||||
merged = merged.fillna("")
|
||||
merged.to_markdown(sys.stdout, index=False, tablefmt="github")
|
||||
Reference in New Issue
Block a user