You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过编程设置JMeter中Throughput Shaping Timer的不同startRPS和endRPS值

动态设置Throughput Shaping Timer的startRPS和endRPS值
  • 确认User Defined Variables中已正确定义startRPS和endRPS变量,填入你需要的起始/结束每秒请求数。

  • 修改JSR223前置处理器代码,确保能正确定位并修改Throughput Shaping Timer的配置:

// 定位目标Throughput Shaping Timer(替换为你的Timer名称)
def throughputTimer = ctx.getThreadGroup().getTestElementList().find { it.getName() == "Throughput Shaping Timer" }

if (throughputTimer) {
    // 获取吞吐量配置集合
    def profileConfigs = throughputTimer.getConfigElement("ThroughputProfile")
    if (profileConfigs) {
        // 遍历配置项,更新startRPS和endRPS
        profileConfigs.each { profile ->
            profile.setProperty("startRPS", vars.get("startRPS"))
            profile.setProperty("endRPS", vars.get("endRPS"))
        }
    }
}

注意:代码中"Throughput Shaping Timer"要和你实际使用的Timer名称完全一致;推荐使用Groovy作为脚本语言,性能优于其他脚本类型。

  • 验证配置:
    • 添加Debug Sampler,查看startRPS和endRPS变量是否正确加载
    • 运行测试后,通过Summary Report或吞吐量监控图表,确认请求量是否按设定的startRPS到endRPS变化

内容的提问来源于stack exchange,提问作者Akshara Sneha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 03:49:49