阿西河

所有教程

公众号
🌙
阿西河前端的公众号

我的收藏

    最近访问  (文章)

      教程列表

      抓包专区
      测试专区

      Locust CSV 统计测试结果

      通过CSV格式自定义测试报告

      如果你希望基于CSV文件使用locust的测试结果。

      在这种场景下下,有两种方法可以执行此操作。

      首先,在通过 Web UI 运行 Locust 时,可以在 Download Data 选项卡下找到CSV文件。

      其次,可以使用带有 flag 的Locust运行脚本,该 flag 将定期保存两个CSV文件。

      如果您打算使用--no-web, flag 自动运行 Locust,这将特别有用:

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

      这些文件将被命名 example_distribution.csvexample_requests.csv (使用时--csv=example)并镜像Locust的内置统计信息页面。

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

      import locust.stats
      locust.stats.CSV_STATS_INTERVAL_SEC = 5 # default is 2 seconds
      

      This data will write two files with _distribution.csv and _requests.csv added to the name you give: 此数据将使用写入两个文件,_distribution.csv and _requests.csv 添加到您提供的名称中:

      $ cat example_distribution.csv
      "Name","# requests","50%","66%","75%","80%","90%","95%","98%","99%","100%"
      "GET /",31,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
      "None Total",69,3,4,4,4,4,4,5,5,5
      

      和:

      $ cat example_requests.csv
      "Method","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
      
      目录
      目录