Files
go-omni/scripts/verifyPerformance.py

53 lines
2.1 KiB
Python
Executable File

#!/usr/bin/env python3
"""Run GoOmni's repeatable stability checks and transport performance baseline."""
import argparse
import os
from pathlib import Path
import subprocess
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--go", default="go")
parser.add_argument("--count", type=int, default=3)
parser.add_argument("--load", action="store_true", help="Also compare isolated servers and idle connection memory")
parser.add_argument("--tls", action="store_true", help="Run the isolated load matrix over TLS")
parser.add_argument("--duration", default="2s", help="Duration per load scenario")
parser.add_argument("--output", help="JSON output path for --load")
args = parser.parse_args()
if args.count < 1:
parser.error("--count must be positive")
root = Path(__file__).resolve().parent.parent
env = dict(os.environ, GOWORK="off")
checks = [
([args.go, "test", "-race", "./..."], "race tests"),
([args.go, "vet", "./..."], "vet"),
([args.go, "build", "./..."], "build"),
(
[args.go, "test", "-run", "^$", "-bench", "^BenchmarkTransport",
"-benchmem", "-count", str(args.count), "./transport"],
"transport benchmarks",
),
]
if args.load:
command = [args.go, "run", "./internal/perfcheck", "--duration", args.duration,
"--count", str(args.count)]
if args.tls:
command.append("--tls")
if args.output:
command += ["--output", str(Path(args.output).resolve())]
checks.append((command, "isolated server concurrency and idle-memory matrix"))
for command, name in checks:
print(f"Running {name}", flush=True)
result = subprocess.run(command, cwd=root, env=env, text=True,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
print(result.stdout, end="")
if result.returncode != 0:
raise SystemExit(f"{name} failed with exit code {result.returncode}")
print("PASS stability checks and transport performance baseline", flush=True)
if __name__ == "__main__":
main()