locust 上传文件性能测试

locust  上传文件性能测试:

代码示例:

from locust import HttpUser, TaskSet, task, os
import json


class MyTask(TaskSet):
@task
def FileTest(self):
self.file_data = {"file": open("D:/test.txt", "rb")}
with self.client.post("/pinter/file/api/upload2", files=self.file_data, name="上传文件接口") as response:
print(response.text)


class WebsiteUser(HttpUser):
tasks = [MyTask]
host = "http://lcocalhost:8080"
min_wait = 5000
max_wait = 9000


if __name__ == "__main__":
os.system("locust -f FileTest.py --host=http://localhost:8088")
posted @   微风轻哨  阅读(218)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· AI Agent开发,如何调用三方的API Function,是通过提示词来发起调用的吗
点击右上角即可分享
微信分享提示