Initial commit of LLM speed test app
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
"""测试用例公共工具"""
|
||||
from ..ollama_client import InferenceResult
|
||||
|
||||
|
||||
def make_result(infer: InferenceResult, iteration: int, **extra) -> dict:
|
||||
"""将一次推理结果转换为用例数据条目"""
|
||||
item = {
|
||||
"iteration": iteration,
|
||||
"ttft_ms": round(infer.ttft_ms, 2),
|
||||
"prefill_ms": round(infer.prefill_ms, 2),
|
||||
"decode_speed_tok_s": round(infer.decode_speed_tok_s, 2),
|
||||
"total_tokens": infer.total_tokens,
|
||||
"prompt_tokens": infer.prompt_tokens,
|
||||
"completion_tokens": infer.completion_tokens,
|
||||
"e2e_ms": round(infer.e2e_ms, 2),
|
||||
"elapsed_ms": round(infer.e2e_ms, 2),
|
||||
"response_length": len(infer.response),
|
||||
}
|
||||
item.update(extra)
|
||||
return item
|
||||
|
||||
|
||||
def case_meta(case_id: str, name: str, description: str,
|
||||
difficulty: str, estimated_seconds: int) -> dict:
|
||||
"""构造用例元数据"""
|
||||
return {
|
||||
"case_id": case_id,
|
||||
"name": name,
|
||||
"description": description,
|
||||
"difficulty": difficulty,
|
||||
"estimated_seconds": estimated_seconds,
|
||||
}
|
||||
Reference in New Issue
Block a user