如何使用数组的长度来设置线程组中的线程数

How to set up the number of threads in a thread group by using the length of an array

我有一个包含多个元素的用户定义变量:

a,b,c,d,e,f

是否可以使用上述 'array' 的长度作为线程数传递? 我尝试使用这样的 beanshell 函数: ${__BeanShell(vars.get("users_username").split(",").length,)} 但它似乎不起作用。

  1. 根据JMeter Functions documentation

    If a function parameter contains a comma, then be sure to escape this with "\", otherwise JMeter will treat it as a parameter delimiter

  2. Since JMeter 3.1 it is recommended to use __groovy() function instead of other scripting options/languages mainly because Groovy performance is much better than alternatives

假设以上所有你可以动态定义线程数为:

${__groovy(vars.get("users_username").split("\,").length,)}