Locust 官方文档 8:提取测试统计信息为 CSV 格式

You may wish to consume your Locust results via a CSV file. In this case, there are two ways to do this.

你可能需要将 Locust 结果 导出为 CSV 文件,有两种方法可以执行此操作。

First, when running Locust with the web UI, you can retrieve CSV files under the Download Data tab.

首先,当使用 Web UI 运行 Locust 时,你可以通过 Download 页面提取到 CSV 文件。

Secondly, you can run Locust with a flag which will periodically save three CSV files. This is particularly useful if you plan on running Locust in an automated way with the --headless flag:

其次,如果你用的是没有 web UI 的方式运行 Locust,你可以通过 --csv 来指定生成 CSV 文件。一旦你使用 --csv, 会定期生成 3 个 CSV 文件。

$ locust -f examples/basic.py --csv=example --headless -t10m

The files will be named example_stats.csv, example_failures.csv and example_history.csv (when using --csv=example).

当你使用 --csv=example 命令时,三个文件分别是,example_stats.csvexample_failures.csvexample_history.csv

The first two files will contain the stats and failures for the whole test run, with a row for every stats entry (URL endpoint) and an aggregated row.

前两个文件将包含整个测试运行的统计信息和失败的条目,每个统计信息条目(URL 端点)都有一行,并且有一个汇总行。

The example_history.csv will get new rows with the current (10 seconds sliding window) stats appanded during the whole test run.

在整个测试运行期间,example_history.csv 每 10 秒会获取一个统计信息的新行。

By default only the Aggregate row is appended regularly to the history stats, but if Locust is started with the --csv-full-history flag, a row for each stats entry (and the Aggregate) is appended every time the stats are written (once every 2 seconds by default).

默认情况下,仅将合计行定期添加到历史记录统计信息中,但是如果 Locust 以 --csv-full-history 标志开始,则每次统计信息被添加时,每个统计信息条目( 包括合计 )都将添加一行写入(默认情况下每 2 秒一次)。

You can also customize how frequently this is written if you desire faster (or slower) writing:

如果希望更快(或更慢)的写入速度,也可以自定义写入频率:

import locust.stats
locust.stats.CSV_STATS_INTERVAL_SEC = 5 # default is 2 seconds
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章