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

Function process_one_length

benchmarks/quick_benchmark.py:504–535  ·  view source on GitHub ↗
(
        # E.g., "ttft"
        metric_attribute_name: str,
        # E.g., "TTFT"
        metric_name: str,
        # E.g., "Time to First Token"
        metric_header: str,
    )

Source from the content-addressed store, hash-verified

502 result[f"p{p_word}_{metric_attribute_name}_ms"] = value
503
504 def process_one_length(
505 # E.g., "ttft"
506 metric_attribute_name: str,
507 # E.g., "TTFT"
508 metric_name: str,
509 # E.g., "Time to First Token"
510 metric_header: str,
511 ):
512 # This function prints and adds statistics of the specified
513 # metric.
514 if metric_attribute_name not in selected_percentile_metrics:
515 return
516 print("{s:{c}^{n}}".format(s=metric_header, n=50, c="-"))
517 print(
518 "{:<40} {:<10.2f}".format(
519 f"Mean {metric_name}:",
520 getattr(metrics, f"mean_{metric_attribute_name}"),
521 )
522 )
523 print(
524 "{:<40} {:<10.2f}".format(
525 f"Median {metric_name}:",
526 getattr(metrics, f"median_{metric_attribute_name}"),
527 )
528 )
529 result[f"mean_{metric_attribute_name}"] = getattr(metrics, f"mean_{metric_attribute_name}")
530 result[f"median_{metric_attribute_name}"] = getattr(metrics, f"median_{metric_attribute_name}")
531 result[f"std_{metric_attribute_name}"] = getattr(metrics, f"std_{metric_attribute_name}")
532 for p, value in getattr(metrics, f"percentiles_{metric_attribute_name}"):
533 p_word = str(int(p)) if int(p) == p else str(p)
534 print("{:<40} {:<10.2f}".format(f"P{p_word} {metric_name}:", value))
535 result[f"p{p_word}_{metric_attribute_name}"] = value
536
537 process_one_length("s_decode", "Decode", "解码速度(tok/s)")
538 process_one_metric("ttft", "TTFT", "Time to First Token")

Callers 1

benchmarkFunction · 0.70

Calls 2

printFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected