import importlib.util, json, sqlite3, sys, time spec = importlib.util.spec_from_file_location("parity", "/tmp/parity.py") sys.argv = ["parity", sys.argv[1] if len(sys.argv) > 1 else "/meta-core/db-cache/cache.db"] src = open("/tmp/parity.py").read().replace("\nmain()\n", "\n") ns = {} exec(compile(src, "parity", "exec"), ns) db = sqlite3.connect(f"file:{DB_PATH}?mode=ro", uri=True) qs = ns["build_queries"](db) for limit in (100, 2000): times = [] worst = [] for q in qs: q = dict(q, limit=limit) try: _, secs = ns["post"](q) except Exception as e: print(" ERROR", e, json.dumps(q)[:150], flush=True) secs = 99 times.append(secs * 1000) worst.append((secs * 1000, json.dumps({k: v for k, v in q.items() if k != "limit"})[:90])) times.sort() print(f"limit={limit}: n={len(times)} p50={times[len(times)//2]:.0f}ms p90={times[int(len(times)*.9)]:.0f}ms max={times[-1]:.0f}ms") for t, q in sorted(worst, reverse=True)[:4]: print(f" {t:7.0f}ms {q}")