python - 蝗虫 : How to make locust run for a specific amount of time

标签 python load-testing locust

官方locustio documentation讲述如何编写无限期运行的简单 locust 任务。

无法找出如何运行持续特定时间的负载,以便测试将在指定的时间间隔后自动停止。

我不需要从 web 界面使用它,命令行/代码选项会很棒。

最佳答案

这个答案已经过时了。 Locust 现在有一个 -t/--run-time 参数用于指定运行时间。见 https://docs.locust.io/en/stable/running-without-web-ui.html?highlight=run-time#setting-a-time-limit-for-the-test

我最近自己开始使用 locust,不幸的是 locust 0.7.1 没有提供基于时间长度终止测试的方法。

但是,它确实提供了一种根据已发出的请求数终止测试的方法。如果您使用 CLI 界面运行 locust,您可以指定它在处理指定数量的请求后停止执行。从 locust --help 输出:

-n NUM_REQUESTS, --num-request=NUM_REQUESTS
       Number of requests to perform. Only used together with --no-web

因此,您可以使用以下内容开始 session :

# locust --clients=20 --hatch-rate=2 --num-request=500

一旦处理了 500 个请求,它应该终止测试。

关于python - 蝗虫 : How to make locust run for a specific amount of time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25392451/

相关文章:

locust - 当指定数量的用户任务完成时停止 Locust

python - 为Google Cloud Machine Learning项目存储图像的最佳方法?

python - Pytest 与线划定的 json

json - 如何在 Artillery.i.o 中运行 Node-js 脚本而不将其包含在负载测试场景中

jmeter - 使用 JMeter 执行负载测试、压力测试、容量测试

Locust.io 设置,未执行拆卸

python - 在Python中的嵌套函数之间共享局部变量

Python - Win32Com - 如何从 Excel 电子表格单元格中提取超链接?

load-testing - Web应用程序负载测试: What metrics to look at?

python - 无法以超过 125 RPS 的速度扩展 Gunicorn/Flask HelloWorld