我的linux服务器上有两个python版本
使用python3
pip3 install locust
过程中有一些报错
第一个报错
gcc: error trying to exec 'cc1plus': execvp: No such file or directory
error: command 'gcc' failed with exit status 1```
第二个报错
src/greenlet/greenlet_refs.hpp:181:19: warning: inline function ‘T* greenlet::refs::PyObjectPointer<T, <anonymous> >::borrow() const [with T = _greenlet; void (* TC)(void*) = greenlet::refs::GreenletChecker]’ used but never defined [enabled by default]
inline T* borrow() const G_NOEXCEPT
^
error: command 'gcc' failed with exit status 1
最后通过下面几个解决
sudo yum install gcc-c++
pip3 install --upgrade pip
pip3 install --upgrade setuptools
pip3 install locust成功后
locust -V 查看版本
创建了一个目录locustTest后,在目录下创建文件baidu_locust.py,里面内容如下
from locust import HttpUser, task, between
class BaiduUser(HttpUser):
wait_time = between(5, 15) # 每个用户执行任务之间等待的时间范围(单位:秒)
@task
def search_baidu(self):
self.client.get("https://www.baidu.com/") # 发送一个GET请求到百度首页
然后用命令执行
locust -f baidu_locust.py
用浏览器打开liunx的IP地址和端口
http://XXXX:8089