jmeter 中的 "if controller" 是否以某种方式降低了吞吐量?
Does "if controller" in jmeter reduces the throughput in someway?
我正在对我的 api 进行性能测试,在尝试一些事情的同时,我发现如果我将我的采样器(http 请求)放在一个总是导致 true 的 "if controller" 中,吞吐量我当我使用没有 if 控制器的采样器时,得到的是一半。为什么会这样?
if-controller中的比较只是比较随机变量是否大于某个阈值。
我的实际用例明显不同,但 if-controller 的这种行为影响了我。
编辑:
这是我的 if-controller 配置的图像。
您应该查看 If Controller 参考,它是使用 If 控制器而不影响性能的一个很好的例子。
Interpret Condition as Variable Expression? If this is selected, then the condition must be an expression that evaluates to "true" (case is ignored). For example, ${FOUND} or ${__jexl3(${VAR} > 100)}
在您的情况下,您应该选中 Interpret Condition as Variable Expression?
复选框并使用以下条件(不带引号):
${__jexl3(${breachPercent} > 10)}
你也可以用__groovy函数替换__jexl3
Checking this and using __jexl3 or __groovy function in Condition is advised for performances
任何测试元素都会增加开销,因此使用 If 控制器的测试计划要么消耗更多资源,要么在资源不足的情况下执行得更慢。
关于 If Controller,确保使用 __groovy() 而不是默认的 JavaScript,因为每次调用 If Controller JMeter 都会使用 JavaScript 解释器评估条件,哪种速度较慢.
因为 JMeter 4.0 如果 Controller 默认将条件解释为变量表达式,理论上应该加快处理速度
还要确保你要么使用解析为 true
的东西,要么使用 __groovy()
函数而不是 JavaScript。
即使假设如果 Controller 的开销,您的测试吞吐量不应下降 2 倍,因此请确保您遵循 JMeter Best Practices 并仔细检查 JMeter 是否有足够的空间根据 CPU 进行操作和内存。
在您使用 If Controller 时,因为您没有检查 "Interpret condition as variable expression",您的代码将由 Javascript 执行,这将根据 documentation 中的警告执行得非常糟糕。
自 JMeter 4.0(强烈建议升级)以来,一条警告清楚地说明了问题:
要修复它,只需使用 __jexl3 函数替换您的代码并检查 "Interpret...":
我正在对我的 api 进行性能测试,在尝试一些事情的同时,我发现如果我将我的采样器(http 请求)放在一个总是导致 true 的 "if controller" 中,吞吐量我当我使用没有 if 控制器的采样器时,得到的是一半。为什么会这样?
if-controller中的比较只是比较随机变量是否大于某个阈值。
我的实际用例明显不同,但 if-controller 的这种行为影响了我。
编辑:
这是我的 if-controller 配置的图像。
您应该查看 If Controller 参考,它是使用 If 控制器而不影响性能的一个很好的例子。
Interpret Condition as Variable Expression? If this is selected, then the condition must be an expression that evaluates to "true" (case is ignored). For example, ${FOUND} or ${__jexl3(${VAR} > 100)}
在您的情况下,您应该选中 Interpret Condition as Variable Expression?
复选框并使用以下条件(不带引号):
${__jexl3(${breachPercent} > 10)}
你也可以用__groovy函数替换__jexl3
Checking this and using __jexl3 or __groovy function in Condition is advised for performances
任何测试元素都会增加开销,因此使用 If 控制器的测试计划要么消耗更多资源,要么在资源不足的情况下执行得更慢。
关于 If Controller,确保使用 __groovy() 而不是默认的 JavaScript,因为每次调用 If Controller JMeter 都会使用 JavaScript 解释器评估条件,哪种速度较慢.
因为 JMeter 4.0 如果 Controller 默认将条件解释为变量表达式,理论上应该加快处理速度
还要确保你要么使用解析为 true
的东西,要么使用 __groovy()
函数而不是 JavaScript。
即使假设如果 Controller 的开销,您的测试吞吐量不应下降 2 倍,因此请确保您遵循 JMeter Best Practices 并仔细检查 JMeter 是否有足够的空间根据 CPU 进行操作和内存。
在您使用 If Controller 时,因为您没有检查 "Interpret condition as variable expression",您的代码将由 Javascript 执行,这将根据 documentation 中的警告执行得非常糟糕。
自 JMeter 4.0(强烈建议升级)以来,一条警告清楚地说明了问题:
要修复它,只需使用 __jexl3 函数替换您的代码并检查 "Interpret...":