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

Function run_load_test

tests/ce/performance/stress_tools.py:90–118  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88
89# ============ 主流程 ============
90async def run_load_test():
91 prompts = await load_data()
92 queue = asyncio.Queue(maxsize=MAX_CONCURRENCY * 5) # 限制队列大小,降低内存占用
93 counter = Counter()
94 latencies = []
95
96 connector = aiohttp.TCPConnector(limit=MAX_CONCURRENCY * 2) # 限制TCP连接
97 timeout = aiohttp.ClientTimeout(total=TIMEOUT)
98
99 async with aiohttp.ClientSession(connector=connector, timeout=timeout) as session:
100 with tqdm(total=TOTAL_REQUESTS, desc="压测进度") as pbar:
101 # 启动 Worker
102 workers = [
103 asyncio.create_task(worker(f"W{i}", session, prompts, counter, latencies, pbar, queue))
104 for i in range(MAX_CONCURRENCY)
105 ]
106
107 # 边生产边消费
108 for i in range(TOTAL_REQUESTS):
109 await queue.put(i)
110
111 # 发送毒丸让 worker 退出
112 for _ in workers:
113 await queue.put(None)
114
115 await queue.join()
116 await asyncio.gather(*workers)
117
118 generate_report(counter, latencies)
119
120
121# ============ 报告输出 ============

Callers 1

stress_tools.pyFile · 0.85

Calls 6

putMethod · 0.95
load_dataFunction · 0.85
CounterStruct · 0.85
workerFunction · 0.85
generate_reportFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected