mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-31 07:36:46 +08:00
Feat: Benchmark CLI additions and documentation (#12536)
### What problem does this PR solve? This PR adds a dedicated HTTP benchmark CLI for RAGFlow chat and retrieval endpoints so we can measure latency/QPS. ### Type of change - [x] Documentation Update - [x] Other (please describe): Adds a CLI benchmarking tool for chat/retrieval latency/QPS --------- Co-authored-by: Liu An <asiro@qq.com>
This commit is contained in:
41
test/benchmark/utils.py
Normal file
41
test/benchmark/utils.py
Normal file
@ -0,0 +1,41 @@
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def eprint(*args, **kwargs):
|
||||
print(*args, file=sys.stderr, **kwargs)
|
||||
|
||||
|
||||
def load_json_arg(value, name):
|
||||
if value is None:
|
||||
return None
|
||||
if isinstance(value, dict):
|
||||
return value
|
||||
if isinstance(value, str) and value.startswith("@"):
|
||||
path = Path(value[1:])
|
||||
try:
|
||||
return json.loads(path.read_text(encoding="utf-8"))
|
||||
except Exception as exc:
|
||||
raise ValueError(f"Failed to read {name} from {path}: {exc}") from exc
|
||||
try:
|
||||
return json.loads(value)
|
||||
except Exception as exc:
|
||||
raise ValueError(f"Invalid JSON for {name}: {exc}") from exc
|
||||
|
||||
|
||||
def split_csv(value):
|
||||
if value is None:
|
||||
return None
|
||||
if isinstance(value, list):
|
||||
return value
|
||||
if isinstance(value, str):
|
||||
items = [item.strip() for item in value.split(",")]
|
||||
return [item for item in items if item]
|
||||
return [value]
|
||||
|
||||
|
||||
def unique_name(prefix):
|
||||
return f"{prefix}_{int(time.time() * 1000)}"
|
||||
|
||||
Reference in New Issue
Block a user