性能测试之Artillery(示例及指标)

本文介绍了如何使用Artillery进行网络性能测试,包括配置参数如持续时间、用户速率,以及创建测试场景。还提及了官方文档的参考和生成JSON报告及可视化的步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

官方文档:https://www.artillery.io/docs/get-started/first-test
PS:文档挺详细,教程比较全

示例

config:
  http:
    extendedMetrics: true
  target: 'http://127.0.0.1:8005'
  phases:
    - duration: 10 # 持续时间
      arrivalRate: 10 # 每秒创建10个用户
      rampTo: 100 # 最多创建100个用户
      name: 预热阶段 # 阶段名
    - duration: 120
      arrivalRate: 100
      rampTo: 100
      name: 正式压测
    # - duration: 30
    #   arrivalRate: 10
    #   rampTo: 30
    #   name: Spike phase
#  plugins:
#    ensure: { }
#    apex: { }
#    metrics-by-endpoint: { }
#  apex:
#    threshold: 100

scenarios:
  - name: "分配玩家"
    weight: 7
    flow:
      - loop:
        - post:
            url: "/room/assignment-user-room"
            json:
              appId: 13
              roomType: 105
              seasonId: 1
              userItem:
                - userId: '1001'
                  roomLevel: 1
        count: 100

  - name: "查询房间所有玩家"
    weight: 7
    flow:
      - loop:
        - post:
            url: "/room/query-all-user"
            json:
              appId: 13
              roomType: 105
              seasonId: 1
              roomId: 100001
        count: 100

PS: 具体参数查看官方文档

2、启动

一、运行并生成JSON报告

  • 使用 -o 参数,先输出JSON:
artillery run artillery/artillery_room.yml -o report.json

二、JSON生成可视化HTML

  • 使用 -output 参数将JSON文件输出 html,进行可视化
artillery report --output report.html report.json

3、性能指标

  • 默认指标:
    在这里插入图片描述

  • http引擎指标:
    在这里插入图片描述

  • 扩展指标:
    需要先启用extendedMetrics ,通过设置来配置为跟踪其他性能config.http.extendedMetrics指标true:

config:
  http:
    extendedMetrics: true

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值