关于压力测试使用的工具

性能测试工具Locust  一个开源性能测试工具

     完全基于python的性能测试工具

    1. 安装python

     2. 安装 locuse

                pip install locustio

        2.2, 通过GitHub上克隆项目安装(Python3推荐):https://github.com/locustio/locust

3、安装 pyzmq

    If you intend to run Locust distributed across multiple processes/machines, we recommend you to also install pyzmq.

如果你打算运行Locust 分布在多个进程/机器,我们建议你也安装pyzmq.

通过pip命令安装。 /> pip install pyzmq

4、安装成功,CMD敲入命令验证。 /> locust –help



编写简单的性能测试脚本                                        

  创建load_test.py文件,通过Python编写性能测试脚本。

复制代码

from locust import HttpLocust, TaskSet, task

class UserBehavior(TaskSet):

    @task(1)
    def baidu(self):
        self.client.get("/")



class WebsiteUser(HttpLocust):
    task_set = UserBehavior
    min_wait = 3000
    max_wait = 6000

复制代码

  创建UserBehavior()类继承TaskSet类,为用户行为。

  创建baidu() 方法表示一个行为,访问百度首页。用@task() 装饰该方法为一个任务。1表示一个Locust实例被挑选执行的权重,数值越大,执行频率越高。在当前UserBehavior()行为下只有一个baidu()任务,所以,这里的权重设置为几,并无影响。

  WebsiteUser()类用于设置性能测试。

  task_set :指向一个定义了的用户行为类。

  min_wait :用户执行任务之间等待时间的下界,单位:毫秒。

  max_wait :用户执行任务之间等待时间的上界,单位:毫秒。

运行性能测试                                                           

  切换到性能测试脚本所在的目录,启动性能测试:

------------------------------------------------------------------

.../> locust -f load_test.py --host=https://www.baidu.com

[2016-11-19 22:38:16,967] fnngj-PC/INFO/locust.main: Starting web monitor at *:8089

[2016-11-19 22:38:16,967] fnngj-PC/INFO/locust.main: Starting Locust 0.7.5

-----------------------------------------------------------------

     load_test.py 为测试脚本,https://www.baidu.com 为测试的网站。

打开浏览器访问:http://127.0.0.1:8089

  Number of users to simulate 设置模拟用户数

  Hatch rate (users spawned/second)  孵化率?不知道怎么翻译,每秒产生(启动)的用户数。

  点击Start swarming 开始运行性能测试。

  如果引起了你的兴趣,剩下的你自个玩吧!难点在性能测试脚本的编写上。

  参考文档:http://docs.locust.io/en/latest/quickstart.html

摘自 https://www.cnblogs.com/fnng/p/6081798.html

性能测试工具2

性能测试之-wrk(转)


ab 无疑是目前最常见的压力测试工具。其典型用法如下:

摘自 https://www.cnblogs.com/elesos/p/6934727.html 

ab wrk  locust   三者使用的工具方法

posted @ 2018-02-02 09:30  JC-0527  阅读(253)  评论(0编辑  收藏  举报