性能測試Locust--(8)CSV存儲測試數據

Locust的測試結果保存到CSV文件,在這種情況下,有兩種方法可以執行此操作。

首先,通過Web UI運行Locust時,可以在“Download Data”選項卡下得到CSV文件。

其次,可以使用標籤運行Locust,該標籤將定期保存兩個CSV文件。如果計劃使用--no-web標籤以自動化方式運行Locust,這將特別有用:

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

文件將被命名爲example_response_times.csvexample_stats.csv (使用--csv=example)並記錄Locust構建的信息。

如果你想要更快(慢)的寫入速度,也可以自動以寫入頻率:

import locust.stats
# 默認爲2秒
locust.stats.CSV_STATS_INTERVAL_SEC = 5

此數據將寫入兩個文件,並將_response_times.csv_stats.csv添加到你提供的名稱中:

$ cat example_response_times.csv
"Name","# requests","50%","66%","75%","80%","90%","95%","98%","99%","99.9%","99.99%","100%"
"GET /",31,4,4,4,4,4,4,4,4,4,4,4
"/does_not_exist",0,"N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A","N/A"
"GET /stats/requests",38,3,4,4,4,4,5,5,5,5,5,5
"None Total",69,3,4,4,4,4,4,5,5,5,5,5

$ cat example_stats.csv
"Type","Name","# requests","# failures","Median response time","Average response time","Min response time","Max response time","Average Content Size","Requests/s"
"GET","/",51,0,4,3,2,6,12274,0.89
"GET","/does_not_exist",0,56,0,0,0,0,0,0.00
"GET","/stats/requests",58,0,3,3,2,5,1214,1.01
"None","Total",109,56,3,3,2,6,6389,1.89
發佈了77 篇原創文章 · 獲贊 121 · 訪問量 21萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章