https://www.toutiao.com/article/7258437079120658996/

https://github.com/ecoAPM/LoadTestToolbox

安装 需要dotnet 6


dotnet tool install --global LoadTestToolbox

LoadTestToolbox 目前包含了三个工具,分别是 drill (钻头), hammer (锤子), nailgun (钉枪)。

drill 钻头

Drill 可以通过在更长的时间内, 以间隔不断的请求,来进行测试应用的长期稳定性。

比如:

ltt drill --url https://www.baidu.com/ --rps 100 --duration 10 --filename chart.png

ltt drill --url https://smdcm.sandieji.tech/ --rps 100 --duration 10 --filename d:/chart.png

在上面的命令中,LoadTestToolbox 将每秒发出 100 个请求(以一致的 20 毫秒间隔),持续 10 秒,请求到 www.baidu.com。

完成后,会输出到笛卡尔图的测试结果,并且显示每个请求和对应的响应时间。

输出结果:

Hammer 锤子

Hammer 可以通过指定范围的并发请求,测试接口的性能,并返回每个请求的平均响应时间。

比如:


ltt hammer --url http://www.qq.com --min 1 --max 100 --filename chart.png

上面的命令会同时发出 1 个请求,然后是 2 个、3 个,依此类推,最多是 100 个并发请求。

输出结果

Nailgun 钉枪

Nailgun 可以对指定的接口发起瞬间的大量请求,来测试接口性能。

比如一次性发起 100 个请求:


~$ ltt nailgun --url http://www.qq.com/ --requests 100 --filename chart.png

输出结果

上面就是 LoadTestToolbox 的三个主要工具。

LoadTestToolbox 还支持各种配置,HTTP 请求方法,请求头,请求体等。

项目地址

https://github.com/ecoAPM/LoadTestToolbox

Drill helps measure long-term stability by constantly requesting a page at consistent intervals over a more extended period of time.

Example:

~$ ltt drill –url http://192.168.1.100/ –rps 500 –duration 10 –filename chart.png

In the above command, LoadTestToolbox will make 500 requests per second (at consistent 20ms intervals) for 10 seconds.

Upon completion, a Cartesian chart is output to the specified file, showing each request and its response time.

Hammer
Hammer helps measure load spikes by “hammering” a specified URL with a given range of simultaneous requests, and returns the average response time for each.

Example:

~$ ltt hammer –url http://192.168.1.100/ –min 1 –max 100 –filename chart.png

The above command will make 1 simultaneous request, then 2, then 3, and so forth, up to 100.

The hammer command is smart about orders of magnitude, so from 10 to 100, it will step up 10 requests at a time (10, 20, 30, etc.); step 100 for 100 to 1000 simultaneous requests (100, 200, …, 1000); and so forth.

A Cartesian chart showing the average response time for each set of requests is output to the specified file upon completion.

Nailgun
Nailgun shows how a specified URL handles a single large influx of requests.

~$ ltt nailgun –url http://192.168.1.100/ –requests 1000 –filename chart.png

The above command sends 1000 requests all at once, and records the response times for each.

A Cartesian chart showing how the URL responded to each of the requests is output to the specified file upon completion.

Options
Required for all requests
-u/–url: the URL to send to
-f/–filename: the file to output the chart to
Optional for any request
-m/–method: the HTTP method to send (default: GET)
-H/–header: the HTTP header(s) to send (default: none)
-b/–body: the HTTP body to send (default: none)
Required for drill
-r/–rps: the number of requests per second to send
-d/–duration: the number of seconds to send requests for
Required for hammer
–min: the minimum number of requests to send
–max: the maximum number of requests to send
Required for nailgun
-r/–requests the number of requests to send

文档更新时间: 2023-07-27 16:51   作者:admin