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

Function process_one_length

benchmarks/benchmark_serving.py:759–790  ·  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

757 )
758
759 def process_one_length(
760 # E.g., "ttft"
761 metric_attribute_name: str,
762 # E.g., "TTFT"
763 metric_name: str,
764 # E.g., "Time to First Token"
765 metric_header: str,
766 ):
767 # This function prints and adds statistics of the specified
768 # metric.
769 if metric_attribute_name not in selected_percentile_metrics:
770 return
771 print("{s:{c}^{n}}".format(s=metric_header, n=50, c="-"))
772 print(
773 "{:<40} {:<10.2f}".format(
774 f"Mean {metric_name}:",
775 getattr(metrics, f"mean_{metric_attribute_name}"),
776 )
777 )
778 print(
779 "{:<40} {:<10.2f}".format(
780 f"Median {metric_name}:",
781 getattr(metrics, f"median_{metric_attribute_name}"),
782 )
783 )
784 result[f"mean_{metric_attribute_name}"] = getattr(metrics, f"mean_{metric_attribute_name}")
785 result[f"median_{metric_attribute_name}"] = getattr(metrics, f"median_{metric_attribute_name}")
786 result[f"std_{metric_attribute_name}"] = getattr(metrics, f"std_{metric_attribute_name}")
787 for p, value in getattr(metrics, f"percentiles_{metric_attribute_name}"):
788 p_word = str(int(p)) if int(p) == p else str(p)
789 print("{:<40} {:<10.2f}".format(f"P{p_word} {metric_name}:", value))
790 result[f"p{p_word}_{metric_attribute_name}"] = value
791
792 process_one_length("s_decode", "Decode", "解码速度(tok/s)")
793 process_one_metric("ttft", "TTFT", "Time to First Token")

Callers 2

benchmarkFunction · 0.70
benchmark_metricsFunction · 0.70

Calls 2

printFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected