蝗虫:如何使蝗虫在特定时间内运行

编程入门 行业动态 更新时间:2024-10-13 12:20:20
本文介绍了蝗虫:如何使蝗虫在特定时间内运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

官方 locustio文档介绍了如何编写可无限期运行的简单蝗虫任务.

official locustio documentation tells about how to write simple locust tasks which run indefinitely.

无法确定如何运行持续特定时间的负载,因此测试将在指定的时间间隔后自动停止.

Couldn't find out how to run load which lasts for a specific amount of time, so that the test will automatically stop after the specified interval.

我不需要Web界面中的命令,命令行/代码选项将非常有用.

I dont need it from the web interface, command line/code option will be just great.

推荐答案

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

I recently started using locust myself and unfortunately locust 0.7.1 does not provide a way to terminate a test based on a length of time.

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

It does however provide a way to terminate the test based on the number of requests that have been issued. If you run locust using the CLI interface you can specify that it stop execution after a specified number of requests have been handled. From the locust --help output:

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

因此,您可以按照以下内容开始会话:

So, you can start a session with something along the lines of:

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

一旦处理了500个请求,就应终止测试.

and once 500 requests have been handled it should terminate the test.

更多推荐

蝗虫:如何使蝗虫在特定时间内运行

本文发布于:2023-11-27 13:29:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638272.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:蝗虫   时间内   在特定

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!