Search code examples
jmetersynchronizationbeanshell

Synchronizing threads in JMeter in middle of test


How to synchronize thread in JMeter? I'd like to have all threads to log in the web application (with a ramp up), then wait and do the loop "compute all" at same time.

If I use the Synchronizing Timer (with a timeout > 0), then the 50 threads are synchronized at every step.

How to make them reach the POST - click on company and then wait?

I could do some BeanShell timer to wait for a given date (but I'm no BeanShell expert). Is there any way to do that in a more JMeter way?

enter image description here


Solution

  • It's explained in the help:

    To apply a timer to a single sampler, add the timer as a child element of the sampler. The timer will be applied before the sampler is executed. To apply a timer after a sampler, either add it to the next sampler, or add it as the child of a Test Action Sampler.

    So to apply synchronization at POST - click on company, you need to put Synchronizing timer under POST - click on company. That way all threads will start POST - click on company at the same time:

    POST - click on company <-- all threads will synch up here
      |-Synchronizing timer
    Loop - computer all
    

    If you rather want them to run POST - click on company unsynchronized, and synchronize just before the loop, then add Test Action Sampler after POST - click on company, and put Synchronizing timer under it:

    POST - click on company
    Test Action Sampler
      |-Synchronizing timer
    Loop - computer all <-- all threads will synch up before loop