MCPcopy Create free account
hub / github.com/PaddlePaddle/Serving / PaddleInferBenchmark

Class PaddleInferBenchmark

python/paddle_serving_server/benchmark_utils.py:29–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27LOG_PATH_ROOT = f"."
28
29class PaddleInferBenchmark(object):
30 def __init__(self,
31 config,
32 model_info: dict={},
33 data_info: dict={},
34 perf_info: dict={},
35 resource_info: dict={},
36 **kwargs):
37 """
38 Construct PaddleInferBenchmark Class to format logs.
39 args:
40 config(paddle.inference.Config): paddle inference config
41 model_info(dict): basic model info
42 {'model_name': 'resnet50'
43 'precision': 'fp32'}
44 data_info(dict): input data info
45 {'batch_size': 1
46 'shape': '3,224,224'
47 'data_num': 1000}
48 perf_info(dict): performance result
49 {'preprocess_time_s': 1.0
50 'inference_time_s': 2.0
51 'postprocess_time_s': 1.0
52 'total_time_s': 4.0}
53 resource_info(dict):
54 cpu and gpu resources
55 {'cpu_rss': 100
56 'gpu_rss': 100
57 'gpu_util': 60}
58 """
59 # PaddleInferBenchmark Log Version
60 self.log_version = "1.0.3"
61
62 # Paddle Version
63 self.paddle_version = paddle.__version__
64 self.paddle_commit = paddle.__git_commit__
65 paddle_infer_info = paddle_infer.get_version()
66 self.paddle_branch = paddle_infer_info.strip().split(': ')[-1]
67
68 # model info
69 self.model_info = model_info
70
71 # data info
72 self.data_info = data_info
73
74 # perf info
75 self.perf_info = perf_info
76 try:
77 # required value
78 self.model_name = model_info['model_name']
79 self.precision = model_info['precision']
80
81 self.batch_size = data_info['batch_size']
82 self.shape = data_info['shape']
83 self.data_num = data_info['data_num']
84
85 self.inference_time_s = round(perf_info['inference_time_s'], 4)
86 except:

Callers 1

handle_benchmarkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected