Skip to content

Commit

Permalink
perf(locust): test Point-In-Polygon endpoint randomly based on a grid…
Browse files Browse the repository at this point in the history
… of points

Picks lat/lon pairs randomly from a grid
  • Loading branch information
TAnas0 committed Oct 7, 2024
1 parent 829c9ec commit 04a4b65
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions scripts/locust.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from locust import HttpUser, between, task
import random


lat_steps = 40 # Number of steps in the latitude direction
lng_steps = 80 # Number of steps in the longitude direction

class ServiceAreaUser(HttpUser):
wait_time = between(1, 2)

# Define the grid parameters

# Generate evenly distributed latitude and longitude values
latitudes = [i * (180 / (lat_steps - 1)) - 90 for i in range(lat_steps)]
longitudes = [i * (360 / (lng_steps - 1)) - 180 for i in range(lng_steps)]

@task
def check_point_in_polygon(self):
# Choose a random lat/lng from the generated grid
lat = random.choice(self.latitudes)
lng = random.choice(self.longitudes)
self.client.get(f"/api/v1/serviceareas/check?lat={lat}&lng={lng}")

0 comments on commit 04a4b65

Please sign in to comment.