Search code examples
jmeterthread-safetycounter

JMeter - Maintaining a global counter


I'm trying to write what sounds like a simple task of maintaining a thread safe global counter by calling the following global function;

${__counter(FALSE,)}

If I run with 100 threads, each thread will have a unique count returned by the function (i.e. from 1 to 100), however each thread seems to keep that same counter variable no matter how many loops it does. i.e. thread 1 has the count still set as '1' on it's second iteration, rather than '101'.

How do I get that counter to update on each loop? It's important that it does this as it appends this counter to a 16 digit user defined starting value, so that the concatenated number is unique for every transaction.


Solution

  • I cannot reproduce your issue using "normal" Thread Group and latest stable JMeter 5.6.2

    enter image description here

    As per design "global" __counter() function returns an incremented value each time it's being called, the question is where did you place the function.