MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / benchmark

Function benchmark

benchmarks/benchmark_serving.py:324–828  ·  view source on GitHub ↗

Benchmarks an API endpoint using a given set of sample inputs and returns

(
    backend: str,
    api_url: str,
    base_url: str,
    model_id: str,
    model_name: str,
    input_requests: list[SampleRequest],
    hyper_parameters: dict,
    logprobs: Optional[int],
    request_rate: float,
    burstiness: float,
    disable_tqdm: bool,
    profile: bool,
    selected_percentile_metrics: list[str],
    selected_percentiles: list[float],
    ignore_eos: bool,
    debug: bool,
    pd_metrics: bool,
    goodput_config_dict: dict[str, float],
    max_concurrency: Optional[int],
    lora_modules: Optional[Iterable[str]],
    extra_body: Optional[dict],
    ip_list: Optional[list[str]] = None,
)

Source from the content-addressed store, hash-verified

322
323
324async def benchmark(
325 backend: str,
326 api_url: str,
327 base_url: str,
328 model_id: str,
329 model_name: str,
330 input_requests: list[SampleRequest],
331 hyper_parameters: dict,
332 logprobs: Optional[int],
333 request_rate: float,
334 burstiness: float,
335 disable_tqdm: bool,
336 profile: bool,
337 selected_percentile_metrics: list[str],
338 selected_percentiles: list[float],
339 ignore_eos: bool,
340 debug: bool,
341 pd_metrics: bool,
342 goodput_config_dict: dict[str, float],
343 max_concurrency: Optional[int],
344 lora_modules: Optional[Iterable[str]],
345 extra_body: Optional[dict],
346 ip_list: Optional[list[str]] = None,
347):
348 """Benchmarks an API endpoint using a given set of sample inputs and returns"""
349 if backend in ASYNC_REQUEST_FUNCS:
350 request_func = ASYNC_REQUEST_FUNCS[backend]
351 else:
352 raise ValueError(f"Unknown backend: {backend}")
353
354 print("Starting initial single prompt test run...")
355 test_prompt, test_output_len, test_no = (
356 input_requests[0].prompt,
357 input_requests[0].expected_output_len,
358 input_requests[0].no,
359 )
360 test_history_QA = input_requests[0].history_QA
361 response_format = input_requests[0].response_format
362 random_flag = input_requests[0].random_flag
363
364 if len(ip_list) >= 1:
365 api_url = f"http://{ip_list[0]}{args.endpoint}"
366
367 test_input = RequestFuncInput(
368 model=model_id,
369 model_name=model_name,
370 prompt=test_prompt,
371 no=test_no,
372 prompt_len=0,
373 history_QA=test_history_QA,
374 hyper_parameters=hyper_parameters,
375 api_url=api_url,
376 output_len=test_output_len,
377 logprobs=logprobs,
378 ignore_eos=ignore_eos,
379 debug=debug,
380 pd_metrics=pd_metrics,
381 extra_body=extra_body,

Callers 2

send_one_batchFunction · 0.90
mainFunction · 0.70

Calls 11

RequestFuncInputClass · 0.90
printFunction · 0.85
process_pd_metricsFunction · 0.85
get_requestFunction · 0.70
limited_request_funcFunction · 0.70
calculate_metricsFunction · 0.70
process_one_lengthFunction · 0.70
process_one_metricFunction · 0.70
closeMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected