From af9096284c38951f0f3ccc0b4905d926129de3f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A7=84=ED=98=84?= Date: Tue, 10 Sep 2024 17:46:12 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20Locust=20=EC=84=B8=ED=8C=85=20-=20S11P2?= =?UTF-8?q?1S002-165?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ai/locust/locustfile.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ai/locust/locustfile.py diff --git a/ai/locust/locustfile.py b/ai/locust/locustfile.py new file mode 100644 index 0000000..9772b65 --- /dev/null +++ b/ai/locust/locustfile.py @@ -0,0 +1,36 @@ +from locust import HttpUser, TaskSet, task, between + +class AIBehavior(TaskSet): + @task(weight = 1) # weight: 해당 task의 빈도수 + def predict(self): + data = { + "project_id": 0, + "image_list": [ + { + "image_id": 12, + "image_url": "test-data/images/image_000000001_jpg.rf.02ab6664294833e5f0e89130ecded0b8.jpg" + }, + { + "image_id": 23, + "image_url": "test-data/images/image_000000002_jpg.rf.8270179e3cd29b97cf502622b381861e.jpg" + }, + { + "image_id": 47, + "image_url": "test-data/images/image_000000003_jpg.rf.db8fd4730b031e35a60e0a60e17a0691.jpg" + } + ] + } + self.client.post("/api/detection", json=data) + + # 앞으로 다른 API 또는 다른 data에 대해서 task 추가 가능 + +class MyLocustUser(HttpUser): + wait_time = between(1,3) + tasks = [AIBehavior.predict] + host = "http://127.0.0.1:8000" + +# shell에 아래 명령어를 입력하여 실행(ai폴더 기준) +# locust -f locust/locustfile.py +# 또는 +# cd locust +# locust \ No newline at end of file