chore: 工具迁入正式工程 + 工程 README + 根目录草稿报告入 ignore
- eip4-poc/tools/{s3_rewriter,loadtest} → tools/(P4 改写器种子与压测 harness 随工程演进,PoC 冻结)
- 新增工程 README(模块图/纪律/常用命令/自举说明)
- 根目录 parity-reports/ 为 CLI 默认输出草稿,入 .gitignore(正式报告在 platform-parity/parity-reports/)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
BIN
tools/loadtest/__pycache__/load_p95.cpython-312.pyc
Normal file
BIN
tools/loadtest/__pycache__/load_p95.cpython-312.pyc
Normal file
Binary file not shown.
137
tools/loadtest/baseline-local-20260610.json
Normal file
137
tools/loadtest/baseline-local-20260610.json
Normal file
@@ -0,0 +1,137 @@
|
||||
{
|
||||
"generated_at": "2026-06-10 23:44:49",
|
||||
"base": "http://localhost:8084",
|
||||
"note": "本地自举环境(M2 Mac/PG15@5433/单实例,数据每实体50行、子表108行);客户库副本规模基线待5435网络恢复后重跑替换",
|
||||
"results": [
|
||||
{
|
||||
"entity": "EIP4PT_ORDERLINE",
|
||||
"requests": 300,
|
||||
"concurrency": 10,
|
||||
"errors": 0,
|
||||
"rps": 247.4,
|
||||
"p50_ms": 37.0,
|
||||
"p90_ms": 51.9,
|
||||
"p95_ms": 56.3,
|
||||
"p99_ms": 65.2,
|
||||
"max_ms": 69.5,
|
||||
"mean_ms": 40.0
|
||||
},
|
||||
{
|
||||
"entity": "EIP4PT_ORDER",
|
||||
"requests": 300,
|
||||
"concurrency": 10,
|
||||
"errors": 0,
|
||||
"rps": 224.7,
|
||||
"p50_ms": 42.3,
|
||||
"p90_ms": 58.8,
|
||||
"p95_ms": 62.9,
|
||||
"p99_ms": 66.1,
|
||||
"max_ms": 76.5,
|
||||
"mean_ms": 44.1
|
||||
},
|
||||
{
|
||||
"entity": "EIP4PT_EMPLOYEE",
|
||||
"requests": 300,
|
||||
"concurrency": 10,
|
||||
"errors": 0,
|
||||
"rps": 114.5,
|
||||
"p50_ms": 81.7,
|
||||
"p90_ms": 117.4,
|
||||
"p95_ms": 121.7,
|
||||
"p99_ms": 130.4,
|
||||
"max_ms": 141.2,
|
||||
"mean_ms": 86.6
|
||||
},
|
||||
{
|
||||
"entity": "EIP4PT_CUSTOMER",
|
||||
"requests": 300,
|
||||
"concurrency": 10,
|
||||
"errors": 0,
|
||||
"rps": 115.3,
|
||||
"p50_ms": 82.9,
|
||||
"p90_ms": 111.3,
|
||||
"p95_ms": 118.7,
|
||||
"p99_ms": 134.8,
|
||||
"max_ms": 143.2,
|
||||
"mean_ms": 85.8
|
||||
},
|
||||
{
|
||||
"entity": "EIP4PT_PRODUCT",
|
||||
"requests": 300,
|
||||
"concurrency": 10,
|
||||
"errors": 0,
|
||||
"rps": 115.8,
|
||||
"p50_ms": 80.9,
|
||||
"p90_ms": 110.3,
|
||||
"p95_ms": 116.4,
|
||||
"p99_ms": 133.8,
|
||||
"max_ms": 139.5,
|
||||
"mean_ms": 85.5
|
||||
},
|
||||
{
|
||||
"entity": "EIP4PT_CONTRACT",
|
||||
"requests": 300,
|
||||
"concurrency": 10,
|
||||
"errors": 0,
|
||||
"rps": 115.6,
|
||||
"p50_ms": 81.3,
|
||||
"p90_ms": 111.7,
|
||||
"p95_ms": 117.3,
|
||||
"p99_ms": 126.3,
|
||||
"max_ms": 136.6,
|
||||
"mean_ms": 85.6
|
||||
},
|
||||
{
|
||||
"entity": "EIP4PT_INVOICE",
|
||||
"requests": 300,
|
||||
"concurrency": 10,
|
||||
"errors": 0,
|
||||
"rps": 113.3,
|
||||
"p50_ms": 83.2,
|
||||
"p90_ms": 112.9,
|
||||
"p95_ms": 122.4,
|
||||
"p99_ms": 134.2,
|
||||
"max_ms": 147.8,
|
||||
"mean_ms": 87.3
|
||||
},
|
||||
{
|
||||
"entity": "EIP4PT_ALLTYPE",
|
||||
"requests": 300,
|
||||
"concurrency": 10,
|
||||
"errors": 0,
|
||||
"rps": 114.5,
|
||||
"p50_ms": 80.2,
|
||||
"p90_ms": 111.2,
|
||||
"p95_ms": 120.7,
|
||||
"p99_ms": 138.8,
|
||||
"max_ms": 146.5,
|
||||
"mean_ms": 86.5
|
||||
},
|
||||
{
|
||||
"entity": "EIP4PT_DEVICE",
|
||||
"requests": 300,
|
||||
"concurrency": 10,
|
||||
"errors": 0,
|
||||
"rps": 115.7,
|
||||
"p50_ms": 80.6,
|
||||
"p90_ms": 111.9,
|
||||
"p95_ms": 121.0,
|
||||
"p99_ms": 135.8,
|
||||
"max_ms": 139.7,
|
||||
"mean_ms": 85.5
|
||||
},
|
||||
{
|
||||
"entity": "EIP4PT_PROJECT",
|
||||
"requests": 300,
|
||||
"concurrency": 10,
|
||||
"errors": 0,
|
||||
"rps": 114.1,
|
||||
"p50_ms": 82.1,
|
||||
"p90_ms": 112.3,
|
||||
"p95_ms": 124.5,
|
||||
"p99_ms": 132.0,
|
||||
"max_ms": 153.1,
|
||||
"mean_ms": 86.8
|
||||
}
|
||||
]
|
||||
}
|
||||
46
tools/loadtest/baseline-local-c4-20260610.json
Normal file
46
tools/loadtest/baseline-local-c4-20260610.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"generated_at": "2026-06-10 23:45:26",
|
||||
"base": "http://localhost:8084",
|
||||
"note": "并发4对照组(连接池max=5,无排队)",
|
||||
"results": [
|
||||
{
|
||||
"entity": "EIP4PT_ORDERLINE",
|
||||
"requests": 300,
|
||||
"concurrency": 4,
|
||||
"errors": 0,
|
||||
"rps": 230.4,
|
||||
"p50_ms": 16.0,
|
||||
"p90_ms": 25.1,
|
||||
"p95_ms": 26.2,
|
||||
"p99_ms": 28.3,
|
||||
"max_ms": 29.5,
|
||||
"mean_ms": 17.3
|
||||
},
|
||||
{
|
||||
"entity": "EIP4PT_ORDER",
|
||||
"requests": 300,
|
||||
"concurrency": 4,
|
||||
"errors": 0,
|
||||
"rps": 233.1,
|
||||
"p50_ms": 15.8,
|
||||
"p90_ms": 24.6,
|
||||
"p95_ms": 26.3,
|
||||
"p99_ms": 27.8,
|
||||
"max_ms": 38.8,
|
||||
"mean_ms": 17.1
|
||||
},
|
||||
{
|
||||
"entity": "EIP4PT_ALLTYPE",
|
||||
"requests": 300,
|
||||
"concurrency": 4,
|
||||
"errors": 0,
|
||||
"rps": 117.5,
|
||||
"p50_ms": 30.5,
|
||||
"p90_ms": 47.5,
|
||||
"p95_ms": 52.1,
|
||||
"p99_ms": 58.0,
|
||||
"max_ms": 64.1,
|
||||
"mean_ms": 34.0
|
||||
}
|
||||
]
|
||||
}
|
||||
111
tools/loadtest/baseline-real-20260611.json
Normal file
111
tools/loadtest/baseline-real-20260611.json
Normal file
@@ -0,0 +1,111 @@
|
||||
{
|
||||
"generated_at": "2026-06-11 11:06:45",
|
||||
"base": "http://localhost:8084",
|
||||
"note": "客户库副本真实数据(共享副本有他方负载,数字含噪声)",
|
||||
"results": [
|
||||
{
|
||||
"entity": "SYS_HZPY",
|
||||
"requests": 150,
|
||||
"concurrency": 4,
|
||||
"errors": 0,
|
||||
"rps": 143.7,
|
||||
"p50_ms": 22.2,
|
||||
"p90_ms": 32.8,
|
||||
"p95_ms": 78.9,
|
||||
"p99_ms": 107.1,
|
||||
"max_ms": 108.0,
|
||||
"mean_ms": 27.5
|
||||
},
|
||||
{
|
||||
"entity": "GB_WORKER",
|
||||
"requests": 150,
|
||||
"concurrency": 4,
|
||||
"errors": 0,
|
||||
"rps": 15.0,
|
||||
"p50_ms": 258.8,
|
||||
"p90_ms": 330.5,
|
||||
"p95_ms": 363.5,
|
||||
"p99_ms": 517.6,
|
||||
"max_ms": 591.5,
|
||||
"mean_ms": 266.1
|
||||
},
|
||||
{
|
||||
"entity": "OA_FILESENDUSER",
|
||||
"requests": 150,
|
||||
"concurrency": 4,
|
||||
"errors": 0,
|
||||
"rps": 111.6,
|
||||
"p50_ms": 28.5,
|
||||
"p90_ms": 39.5,
|
||||
"p95_ms": 113.3,
|
||||
"p99_ms": 115.3,
|
||||
"max_ms": 115.8,
|
||||
"mean_ms": 35.5
|
||||
},
|
||||
{
|
||||
"entity": "PM_PROJECT_TASK",
|
||||
"requests": 150,
|
||||
"concurrency": 4,
|
||||
"errors": 0,
|
||||
"rps": 46.2,
|
||||
"p50_ms": 72.2,
|
||||
"p90_ms": 142.1,
|
||||
"p95_ms": 160.2,
|
||||
"p99_ms": 189.3,
|
||||
"max_ms": 192.0,
|
||||
"mean_ms": 85.9
|
||||
},
|
||||
{
|
||||
"entity": "OA_SEALUSEAPPLY",
|
||||
"requests": 150,
|
||||
"concurrency": 4,
|
||||
"errors": 0,
|
||||
"rps": 64.0,
|
||||
"p50_ms": 49.1,
|
||||
"p90_ms": 130.9,
|
||||
"p95_ms": 134.7,
|
||||
"p99_ms": 139.5,
|
||||
"max_ms": 181.5,
|
||||
"mean_ms": 60.9
|
||||
},
|
||||
{
|
||||
"entity": "PM_BUILDERSDIARY",
|
||||
"requests": 150,
|
||||
"concurrency": 4,
|
||||
"errors": 0,
|
||||
"rps": 74.9,
|
||||
"p50_ms": 42.2,
|
||||
"p90_ms": 117.5,
|
||||
"p95_ms": 129.1,
|
||||
"p99_ms": 132.5,
|
||||
"max_ms": 136.6,
|
||||
"mean_ms": 52.8
|
||||
},
|
||||
{
|
||||
"entity": "PM_CONTRACTBALANCE",
|
||||
"requests": 150,
|
||||
"concurrency": 4,
|
||||
"errors": 0,
|
||||
"rps": 12.1,
|
||||
"p50_ms": 299.9,
|
||||
"p90_ms": 417.4,
|
||||
"p95_ms": 465.2,
|
||||
"p99_ms": 530.9,
|
||||
"max_ms": 680.1,
|
||||
"mean_ms": 329.5
|
||||
},
|
||||
{
|
||||
"entity": "HR_ATTENDLOG",
|
||||
"requests": 150,
|
||||
"concurrency": 4,
|
||||
"errors": 0,
|
||||
"rps": 4.1,
|
||||
"p50_ms": 923.3,
|
||||
"p90_ms": 1096.8,
|
||||
"p95_ms": 1179.8,
|
||||
"p99_ms": 1322.3,
|
||||
"max_ms": 1487.4,
|
||||
"mean_ms": 959.0
|
||||
}
|
||||
]
|
||||
}
|
||||
20
tools/loadtest/baseline-real-heavy-20260611.json
Normal file
20
tools/loadtest/baseline-real-heavy-20260611.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"generated_at": "2026-06-11 11:08:00",
|
||||
"base": "http://localhost:8084",
|
||||
"note": "重查询实体单列(DISTINCT+4 LATERAL)",
|
||||
"results": [
|
||||
{
|
||||
"entity": "PM_PAYMENTAPPLY",
|
||||
"requests": 30,
|
||||
"concurrency": 2,
|
||||
"errors": 0,
|
||||
"rps": 0.5,
|
||||
"p50_ms": 4192.9,
|
||||
"p90_ms": 4566.3,
|
||||
"p95_ms": 4630.0,
|
||||
"p99_ms": 4649.2,
|
||||
"max_ms": 4649.4,
|
||||
"mean_ms": 4203.9
|
||||
}
|
||||
]
|
||||
}
|
||||
148
tools/loadtest/load_p95.py
Normal file
148
tools/loadtest/load_p95.py
Normal file
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
EIP4 M0-C3:高频实体基础压测,输出 P50/P90/P95/P99 延迟基线。
|
||||
零依赖(标准库)。用法:
|
||||
python3 load_p95.py --base http://localhost:8084 \
|
||||
--entities SYS_USERGROUP,PM_LABORCOMPANY --requests 200 --concurrency 10 \
|
||||
--out-md 基线.md --out-json 基线.json
|
||||
说明:
|
||||
- Top10「高频」实体在客户生产访问日志可得前,以样本库行数 Top 实体为代理口径,
|
||||
正式基线须在客户库副本(192.168.20.68:5435)网络恢复后重跑并替换。
|
||||
- 每实体先 3 次预热(不计入),再发 --requests 次列表查询(page=1,perPage=20)。
|
||||
"""
|
||||
import argparse
|
||||
import json
|
||||
import statistics
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
from queue import Queue
|
||||
|
||||
|
||||
def percentile(sorted_vals, p):
|
||||
if not sorted_vals:
|
||||
return None
|
||||
k = (len(sorted_vals) - 1) * p / 100.0
|
||||
f = int(k)
|
||||
c = min(f + 1, len(sorted_vals) - 1)
|
||||
return sorted_vals[f] + (sorted_vals[c] - sorted_vals[f]) * (k - f)
|
||||
|
||||
|
||||
def fire(url, timeout):
|
||||
t0 = time.perf_counter()
|
||||
try:
|
||||
with urllib.request.urlopen(url, timeout=timeout) as r:
|
||||
body = r.read()
|
||||
ms = (time.perf_counter() - t0) * 1000
|
||||
ok = r.status == 200
|
||||
# 引擎错误也可能 200 包 status!=0,粗校验 JSON 外形
|
||||
if ok and body[:1] not in (b"{", b"["):
|
||||
ok = False
|
||||
return ms, ok
|
||||
except Exception:
|
||||
return (time.perf_counter() - t0) * 1000, False
|
||||
|
||||
|
||||
def bench_entity(base, entity, n_req, concurrency, timeout):
|
||||
url = f"{base}/api/entity/{entity}/list?page=1&perPage=20"
|
||||
for _ in range(3): # 预热
|
||||
fire(url, timeout)
|
||||
|
||||
q = Queue()
|
||||
for _ in range(n_req):
|
||||
q.put(url)
|
||||
lat, errs = [], 0
|
||||
lock = threading.Lock()
|
||||
|
||||
def worker():
|
||||
nonlocal errs
|
||||
while True:
|
||||
try:
|
||||
u = q.get_nowait()
|
||||
except Exception:
|
||||
return
|
||||
ms, ok = fire(u, timeout)
|
||||
with lock:
|
||||
lat.append(ms)
|
||||
if not ok:
|
||||
errs += 1
|
||||
q.task_done()
|
||||
|
||||
t0 = time.perf_counter()
|
||||
threads = [threading.Thread(target=worker, daemon=True) for _ in range(concurrency)]
|
||||
for t in threads:
|
||||
t.start()
|
||||
for t in threads:
|
||||
t.join()
|
||||
wall = time.perf_counter() - t0
|
||||
|
||||
s = sorted(lat)
|
||||
return {
|
||||
"entity": entity,
|
||||
"requests": n_req,
|
||||
"concurrency": concurrency,
|
||||
"errors": errs,
|
||||
"rps": round(n_req / wall, 1) if wall > 0 else None,
|
||||
"p50_ms": round(percentile(s, 50), 1),
|
||||
"p90_ms": round(percentile(s, 90), 1),
|
||||
"p95_ms": round(percentile(s, 95), 1),
|
||||
"p99_ms": round(percentile(s, 99), 1),
|
||||
"max_ms": round(s[-1], 1) if s else None,
|
||||
"mean_ms": round(statistics.fmean(s), 1) if s else None,
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--base", default="http://localhost:8084")
|
||||
ap.add_argument("--entities", required=True, help="逗号分隔实体表名")
|
||||
ap.add_argument("--requests", type=int, default=200)
|
||||
ap.add_argument("--concurrency", type=int, default=10)
|
||||
ap.add_argument("--timeout", type=float, default=30.0)
|
||||
ap.add_argument("--out-md", default=None)
|
||||
ap.add_argument("--out-json", default=None)
|
||||
ap.add_argument("--note", default="本地自举环境基线;客户库副本基线待网络恢复后重跑")
|
||||
args = ap.parse_args()
|
||||
|
||||
results = []
|
||||
for e in [x.strip() for x in args.entities.split(",") if x.strip()]:
|
||||
print(f"压测 {e} ...", flush=True)
|
||||
r = bench_entity(args.base, e, args.requests, args.concurrency, args.timeout)
|
||||
print(f" P95={r['p95_ms']}ms P99={r['p99_ms']}ms RPS={r['rps']} 错误={r['errors']}")
|
||||
results.append(r)
|
||||
|
||||
payload = {
|
||||
"generated_at": time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
"base": args.base,
|
||||
"note": args.note,
|
||||
"results": results,
|
||||
}
|
||||
if args.out_json:
|
||||
with open(args.out_json, "w", encoding="utf-8") as f:
|
||||
json.dump(payload, f, ensure_ascii=False, indent=2)
|
||||
if args.out_md:
|
||||
lines = [
|
||||
"# C3 压测基线",
|
||||
"",
|
||||
f"> 生成时间:{payload['generated_at']} | 目标:{args.base}",
|
||||
f"> 口径:每实体 {args.requests} 请求 / 并发 {args.concurrency} / list 第 1 页 20 行",
|
||||
f"> {args.note}",
|
||||
"",
|
||||
"| 实体 | P50(ms) | P90(ms) | P95(ms) | P99(ms) | Max(ms) | RPS | 错误 |",
|
||||
"|------|--------:|--------:|--------:|--------:|--------:|----:|----:|",
|
||||
]
|
||||
for r in results:
|
||||
lines.append(
|
||||
f"| {r['entity']} | {r['p50_ms']} | {r['p90_ms']} | {r['p95_ms']} "
|
||||
f"| {r['p99_ms']} | {r['max_ms']} | {r['rps']} | {r['errors']} |")
|
||||
with open(args.out_md, "w", encoding="utf-8") as f:
|
||||
f.write("\n".join(lines) + "\n")
|
||||
bad = sum(r["errors"] for r in results)
|
||||
print(f"完成:{len(results)} 实体,总错误 {bad}")
|
||||
sys.exit(1 if bad else 0)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user