초기 커밋 — 협상 AI 에이전트 정본: 엔진·데모 콘솔·측정 인프라·증빙
- server/: FastAPI 협상 엔진 (5라운드, Q-Table/UCB, 페르소나 계측, :53117) - frontend/: 데모 콘솔 (React+Tailwind → nginx, /api 프록시) - eval/·testdata/: 지표 8종 측정 하네스 + 재현 가능 테스트셋 - results/: 측정 증빙 (지표별 result+provenance, raw 원본 동결+SHA256) ① 86.0 · ② 76.0 · ③ 5.99% · ⑥ p95 3.61ms · ⑦ 611만/년 · ⑧ 91/100 · ⑨ 99.71 · ⑩ 97.99 - docker-compose.yml + run.sh: backend+frontend 일괄 기동 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0112XUWF4bc3gGrEt8vsYCzy
This commit is contained in:
commit
dfb9ad6e66
268 files changed
+164241
No files matched your search
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python3
|
||||
"""⑥ 답변속도 — 서버 계측(response_time.jsonl) 집계기.
|
||||
|
||||
서버가 /v1/nego/chat 요청마다 기록한 처리시간(요청 수신 → 응답 완료 ms)을 집계한다.
|
||||
측정 구간: 답변 생성 엔진 내부 처리 (HTTP 미들웨어 계측, localhost 왕복 제외분 없음)
|
||||
|
||||
사용:
|
||||
python aggregate.py # 서버 data/response_time.jsonl 전체
|
||||
python aggregate.py --since 2026-08-28T15:14 # 특정 시각 이후만 (본측정 구간 등)
|
||||
python aggregate.py --target 600
|
||||
|
||||
출력: result.json (n, p50/p95/p99/max, 목표 대비 판정)
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
HERE = Path(__file__).parent
|
||||
DEFAULT_LOG = HERE.parent.parent / "server" / "data" / "response_time.jsonl"
|
||||
|
||||
|
||||
def percentile(sorted_vals, p):
|
||||
if not sorted_vals:
|
||||
return None
|
||||
k = (len(sorted_vals) - 1) * p / 100
|
||||
lo, hi = int(k), min(int(k) + 1, len(sorted_vals) - 1)
|
||||
return round(sorted_vals[lo] + (sorted_vals[hi] - sorted_vals[lo]) * (k - lo), 2)
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--log", default=str(DEFAULT_LOG))
|
||||
ap.add_argument("--since", default=None, help="ISO 시각 이후 표본만 (예: 2026-08-28T15:14)")
|
||||
ap.add_argument("--until", default=None)
|
||||
ap.add_argument("--target", type=float, default=600.0, help="목표 ms")
|
||||
args = ap.parse_args()
|
||||
|
||||
rows = []
|
||||
for line in Path(args.log).read_text(encoding="utf-8").splitlines():
|
||||
if not line.strip():
|
||||
continue
|
||||
r = json.loads(line)
|
||||
if args.since and r["ts"] < args.since:
|
||||
continue
|
||||
if args.until and r["ts"] > args.until:
|
||||
continue
|
||||
if r.get("status") == 200:
|
||||
rows.append(r)
|
||||
|
||||
vals = sorted(r["ms"] for r in rows)
|
||||
n = len(vals)
|
||||
p95 = percentile(vals, 95)
|
||||
out = {
|
||||
"측정구간": "서버 요청 수신 → 응답 완료 (HTTP 미들웨어 계측)",
|
||||
"표본": {"log": args.log, "since": args.since, "until": args.until, "n": n},
|
||||
"ms": {
|
||||
"p50": percentile(vals, 50), "p95": p95, "p99": percentile(vals, 99),
|
||||
"min": round(vals[0], 2) if vals else None,
|
||||
"max": round(vals[-1], 2) if vals else None,
|
||||
"mean": round(sum(vals) / n, 2) if n else None,
|
||||
},
|
||||
"target_ms": args.target,
|
||||
"판정기준": "p95 ≤ 목표",
|
||||
"verdict": "PASS" if (p95 is not None and p95 <= args.target) else "FAIL",
|
||||
}
|
||||
(HERE / "result.json").write_text(json.dumps(out, ensure_ascii=False, indent=2),
|
||||
encoding="utf-8")
|
||||
print(json.dumps(out, ensure_ascii=False, indent=1))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env python3
|
||||
"""⑥ 답변속도 — 정식 부하 측정 (표준 라이브러리만, 기존 04 bench 방식 계승).
|
||||
|
||||
측정 구간: 답변 생성 엔진 요청 수신 → 응답 완료 (HTTP 왕복, localhost)
|
||||
측정 경로: --profile heavy = 가격협상 진입 (Q-Table 카드 선택 경로, 기본)
|
||||
--profile light = 고정 스크립트 스텝(시작)
|
||||
부하 형태: 동시 사용자(--vus) × 총 요청(--n), 웜업(--warmup) 제외 후 집계
|
||||
|
||||
사용: python bench.py [--n 1000] [--warmup 50] [--vus 10] [--target 600]
|
||||
출력: result_bench_<profile>.json (p50/p95/p99, 판정) + detail_bench_<profile>.jsonl
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import time
|
||||
import urllib.request
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from pathlib import Path
|
||||
|
||||
HERE = Path(__file__).parent
|
||||
|
||||
HEAVY = {"rq_type": "재협상", "session_id": "BENCH", "step": "가격협상_확인", "index": 5,
|
||||
"user_input": "예", "item_price": 163600, "revenue": 163600, "dist": "R",
|
||||
"partners_yn": "없음", "partners": 0, "anchor": 8099, "target": 8180,
|
||||
"initial": 9000, "input": 9000, "iteration": 0, "is_new_quote": True,
|
||||
"profiling": False}
|
||||
LIGHT = {"rq_type": "재협상", "session_id": "BENCH", "step": "시작", "index": 0,
|
||||
"profiling": False}
|
||||
|
||||
|
||||
def once(url: str, body: bytes) -> float:
|
||||
t0 = time.perf_counter()
|
||||
req = urllib.request.Request(url, body, {"Content-Type": "application/json"})
|
||||
with urllib.request.urlopen(req, timeout=60) as r:
|
||||
r.read()
|
||||
return (time.perf_counter() - t0) * 1000
|
||||
|
||||
|
||||
def percentile(vals, p):
|
||||
if not vals:
|
||||
return None
|
||||
k = (len(vals) - 1) * p / 100
|
||||
lo, hi = int(k), min(int(k) + 1, len(vals) - 1)
|
||||
return round(vals[lo] + (vals[hi] - vals[lo]) * (k - lo), 2)
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--url", default="http://127.0.0.1:53117/v1/nego/chat")
|
||||
ap.add_argument("--n", type=int, default=1000)
|
||||
ap.add_argument("--warmup", type=int, default=50)
|
||||
ap.add_argument("--vus", type=int, default=10, help="동시 사용자 수")
|
||||
ap.add_argument("--profile", default="heavy", choices=["heavy", "light"])
|
||||
ap.add_argument("--target", type=float, default=600.0)
|
||||
args = ap.parse_args()
|
||||
|
||||
body = json.dumps(HEAVY if args.profile == "heavy" else LIGHT).encode()
|
||||
|
||||
# 웜업 (집계 제외)
|
||||
for _ in range(args.warmup):
|
||||
once(args.url, body)
|
||||
|
||||
t_start = time.perf_counter()
|
||||
with ThreadPoolExecutor(max_workers=args.vus) as ex:
|
||||
samples = list(ex.map(lambda _: once(args.url, body), range(args.n)))
|
||||
wall = time.perf_counter() - t_start
|
||||
|
||||
with open(HERE / f"detail_bench_{args.profile}.jsonl", "w", encoding="utf-8") as f:
|
||||
for ms in samples:
|
||||
f.write(json.dumps({"ms": round(ms, 3)}) + "\n")
|
||||
|
||||
vals = sorted(samples)
|
||||
p95 = percentile(vals, 95)
|
||||
out = {
|
||||
"측정구간": "요청 수신 → 응답 완료 (HTTP 왕복, localhost)",
|
||||
"부하": {"profile": args.profile, "n": args.n, "warmup_제외": args.warmup,
|
||||
"동시사용자": args.vus, "총소요_초": round(wall, 2),
|
||||
"처리율_req_s": round(args.n / wall, 1)},
|
||||
"ms": {"p50": percentile(vals, 50), "p95": p95, "p99": percentile(vals, 99),
|
||||
"min": round(vals[0], 2), "max": round(vals[-1], 2),
|
||||
"mean": round(sum(vals) / len(vals), 2)},
|
||||
"target_ms": args.target,
|
||||
"판정기준": "p95 ≤ 목표",
|
||||
"verdict": "PASS" if p95 is not None and p95 <= args.target else "FAIL",
|
||||
}
|
||||
(HERE / f"result_bench_{args.profile}.json").write_text(
|
||||
json.dumps(out, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
print(json.dumps(out, ensure_ascii=False, indent=1))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user