From 9bb7638402e03d1ea6009e939b8c24acee4195cf Mon Sep 17 00:00:00 2001 From: kshtiijrajsharma Date: Thu, 7 Dec 2023 16:26:04 +0545 Subject: [PATCH] added locust script and readme update --- README.md | 13 ++++++++++++- locust.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 locust.py diff --git a/README.md b/README.md index 28e2d2e..100df02 100644 --- a/README.md +++ b/README.md @@ -45,4 +45,15 @@ Works on CPU ! Can work on serverless functions, No other dependencies to run pr There is another postprocessing option that supports distance threshold between polygon for merging them , If it is useful for you install raster2polygon by : ``` pip install raster2polygon -``` \ No newline at end of file +``` + + +## Load Testing + +In order to perform load testing we use Locust , To enable this hit following command within the root dir +**Caution : Always take permission of server admin before you perform load test** + +``` +locust -f locust.py +``` +Populate your HOST and replace it with BASE URL of the Predictor URL \ No newline at end of file diff --git a/locust.py b/locust.py new file mode 100644 index 0000000..50ddf20 --- /dev/null +++ b/locust.py @@ -0,0 +1,34 @@ +from locust import HttpUser, between, task + + +class MyUser(HttpUser): + wait_time = between(1, 3) # Time between requests + + @task + def predict_api(self): + payload = { + "bbox": [ + 100.56228021333352, + 13.685230854641182, + 100.56383321235313, + 13.685961853747969, + ], + "checkpoint": "/mnt/efsmount/data/trainings/dataset_58/output/training_324/checkpoint.tflite", + "zoom_level": 20, + "source": "https://tiles.openaerialmap.org/6501a65c0906de000167e64d/0/6501a65c0906de000167e64e/{z}/{x}/{y}", + "use_josm_q": "false", + "merge_adjacent_polygons": "true", + "confidence": 50, + "max_angle_change": 15, + "skew_tolerance": 15, + "tolerance": 0.5, + "area_threshold": 3, + "tile_overlap_distance": 0.15, + } + + headers = {"Content-Type": "application/json"} + + response = self.client.post("predict/", json=payload, headers=headers) + + # Print response status code and content + print(f"Response Status Code: {response.status_code}, Content: {response.text}")