1. 程式人生 > >(四)Locust no-web模式

(四)Locust no-web模式

clas info 工具 web req comment 虛擬 設置 就是

轉:

http://www.testclass.net/locust/no-web-run/

熟悉 Apache ab 工具的同學都知道,它是沒有界面的,通過命令行執行。 Locust 同樣也提供的命令行運行,好處就是更節省客戶端資源。

命令行運行 Locust 測試


以上一節的 baidu 首頁測試(load_test.py)為例 通過 no-web 模式運行測試。

> locust -f load_test.py --host=https://www.baidu.com --no-web -c 10 -r 2 -t 1m

[2017-10-30 22:17:30,292] DESKTOP-SMGQBBM/INFO/locust.main: Run time limit set to 60 seconds
[2017-10-30 22:17:30,302] DESKTOP-SMGQBBM/INFO/locust.main: Starting Locust 0.8
[2017-10-30 22:17:30,302] DESKTOP-SMGQBBM/INFO/locust.runners: Hatching and swarming 10 clients at the rate 2 clients/s...
 Name                                                          # reqs      # fails     Avg     Min     Max  |  Median   req/s

....


 [2017-10-30 22:18:30,301] DESKTOP-SMGQBBM/INFO/locust.main: Time limit reached. Stopping Locust.
 [2017-10-30 22:18:30,302] DESKTOP-SMGQBBM/INFO/locust.main: Shutting down (exit code 0), bye.
  Name                                                          # reqs      # fails     Avg     Min     Max  |  Median   req/s
 --------------------------------------------------------------------------------------------------------------------------------------------
  GET /                                                            117     0(0.00%)      31      17      96  |      28    2.10
 --------------------------------------------------------------------------------------------------------------------------------------------
  Total                                                            117     0(0.00%)                                       2.10

 Percentage of the requests completed within given times
  Name                                                           # reqs    50%    66%    75%    80%    90%    95%    98%    99%   100%
 --------------------------------------------------------------------------------------------------------------------------------------------
  GET /                                                             117     28     30     36     37     49     62     69     72     96
 --------------------------------------------------------------------------------------------------------------------------------------------
  Total                                                             117     28     30     36     37     49     62     69     72     96

啟動參數:

–no-web 表示不使用Web界面運行測試。

-c 設置虛擬用戶數。

-r 設置每秒啟動虛擬用戶數。

-t 設置設置運行時間。

(四)Locust no-web模式