【问题标题】:Locust: No statistics shown蝗虫:未显示统计数据
【发布时间】:2022-11-03 01:37:46
【问题描述】:

我是 Locust 的新手,我正在尝试记录 POST 请求的统计信息,并且我正在使用以下代码以及对 locust 的通用调用。

import json

from locust import HttpUser, task, between
import cfg

class BasicUser(HttpUser):
    wait_time = between(1, 3)
    v1_data = json.load(open("v1_sample_data.json", "r"))

    @task
    def get_v1_prediction(self):
        route = "/" + cfg.lookup("model.v1.route")
        response = self.client.post(
            route,
            json=self.v1_data,
            catch_response=True,
            name="API Call"
        )
        print(response.text)

当我开始一个实验时,主机调用成功,response.text有预期值,反复打印到控制台。但是,不会记录统计信息。

当我使用 GET 请求代替 POST 而不传递数据时,会记录统计信息(尽管它只是失败,因为 Web 应用程序只允许 POST 请求)。知道这里发生了什么吗?

【问题讨论】:

    标签: python locust


    【解决方案1】:

    catch_response=True 是罪魁祸首。

    【讨论】:

      猜你喜欢
      • 2019-04-09
      • 1970-01-01
      • 2021-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-13
      • 2019-01-31
      相关资源
      最近更新 更多