我如何自己处理凝聚力的汇总数据?

发布于 2025-01-24 21:39:42 字数 63 浏览 3 评论 0原文

我想以自己的格式打印请求的各个参数。我只找到CSV格式。我可以在代码中获取每个数据吗?我可以使用任何事件挂钩吗?

I want to print the individual parameters of the request result in my own format.I found the csv format only.How could I get each data in the code?Is there any event hooks can i use?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沫雨熙 2025-01-31 21:39:42

您可以使用事件挂钩。在下面的示例中,我使用了“退出”事件,但是您可以使用适合您用例的其他挂钩。

class LoggedInUser(FastHttpUser):
host = "https://yourhost.com"
task_set = UserBehaviour

@events.quitting.add_listener
def do_checks(environment, **_kw):
    # doing aggregation on master node
    # if you want to run in all nodes remove this condition
    if isinstance(environment.runner, WorkerRunner): 
        return

    for x in environment.runner.stats.serialize_stats():
        name = x.get('name')
        total_response_time = float(x.get('total_response_time'))
        num_requests = int(x.get("num_requests"))
        min_response_time = float(x.get("min_response_time"))
        max_response_time = float(x.get("max_response_time"))
        average = total_response_time / num_requests

You can use event hooks. In the sample below, I have used the "quitting" event, but you can use any other hook appropriate for your use case.

class LoggedInUser(FastHttpUser):
host = "https://yourhost.com"
task_set = UserBehaviour

@events.quitting.add_listener
def do_checks(environment, **_kw):
    # doing aggregation on master node
    # if you want to run in all nodes remove this condition
    if isinstance(environment.runner, WorkerRunner): 
        return

    for x in environment.runner.stats.serialize_stats():
        name = x.get('name')
        total_response_time = float(x.get('total_response_time'))
        num_requests = int(x.get("num_requests"))
        min_response_time = float(x.get("min_response_time"))
        max_response_time = float(x.get("max_response_time"))
        average = total_response_time / num_requests
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文