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