Home >Backend Development >Python Tutorial >Detailed explanation of the installation and use of Python3.6 performance testing framework Locust (picture)
The following editor will bring you an article on how to install and use the Python 3.6 performance testing framework Locust (detailed explanation). The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor to take a look
Background
The construction and use of Python3.6 performance testing framework Locust
Basics
Python version: python3.6
Development tool: pycharm
Installation and configuration of Locust
Click "File" → "setting"
Click "setting" to enter the setting window and select "Project Interpreter"
Click "+"
Enter the required "Locust" and click "Install Package"
You can use it after the installation is complete.
After installing the Locust tool, you only need to write a simple Python file to load test the system. Here's an example:
from locust import Locust, TaskSet, task class UserBehavior(TaskSet): @task def job(self): pass class User(Locust): task_set = UserBehavior min_wait = 1000 max_wait = 3000
Then enter in the terminal:
##
mars@mars-Ideapad-V460:~/test$ locust [2015-09-12 10:46:36,876] mars-Ideapad-V460/INFO/locust.main: Starting web monitor at *:8089 [2015-09-12 10:46:36,919] mars-Ideapad-V460/INFO/locust.main: Starting Locust 0.7.3Then visit localhost in the browser: 8089, the following page pops up: The first line Number of users to simulate is the number of simulated users, and the second line Hatch rate (users spawned/second represents the number of simulated users) Speed, test statistics will be started after all users are generated. After filling in, click "Start swarming" to start the test:
The above is the detailed content of Detailed explanation of the installation and use of Python3.6 performance testing framework Locust (picture). For more information, please follow other related articles on the PHP Chinese website!