Search code examples
jmeterperformance-testing

Jmeter - current active threads


I need to get the value of number of threads that are active in an iteration

Is there any function or command that returns that number of active threads in an iteration?


Solution

  • You can do it using __groovy() function, something like:

    ${__groovy(ctx.getThreadGroup().getNumberOfThreads(),)}
    

    will return the number of currently active threads (virtual users)

    In the above snippet ctx stands for JMeterContext class instance, see Top 8 JMeter Java Classes You Should Be Using with Groovy article for more information on this and other JMeter API shorthands available for the JSR223 Test Elements and __groovy() function