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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章