-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from yuriihavrylko/feature/l11t1-load-test
L11T1 Load testing with locust
- Loading branch information
Showing
4 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ accelerate==0.25.0 | |
datasets==2.16.1 | ||
wandb==0.16.1 | ||
httpx==0.23.0 | ||
locust==2.20.1 | ||
ipykernel==6.28.0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import numpy as np | ||
from locust import HttpUser, between, task | ||
|
||
movie_reviews = [ | ||
"Scientists Discover New Species in Amazon Rainforest", | ||
"Breakthrough in Cancer Research Offers Hope for Patients", | ||
"Global Leaders Unveil Plan for Sustainable Energy Future", | ||
"Artificial Intelligence Revolutionizing Healthcare Diagnostics", | ||
"Mars Rover Sends Stunning Images of Martian Landscape", | ||
"World-renowned Chef Opens Innovative Plant-Based Restaurant", | ||
"International Space Station Celebrates 25 Years in Orbit", | ||
"Groundbreaking Study Reveals Secrets of Longevity", | ||
"Major Tech Company Launches Cutting-edge Augmented Reality Device", | ||
"Humanitarian Aid Reaches Remote Areas Amidst Global Crisis" | ||
] | ||
|
||
|
||
class PredictUser(HttpUser): | ||
wait_time = between(1, 5) | ||
|
||
@task | ||
def predict(self): | ||
num_of_review = np.random.randint(1, 100) | ||
reviews = np.random.choice(movie_reviews, size=num_of_review, replace=True) | ||
self.client.post("/predict", json={"text": reviews.tolist()}) |