简体   繁体   中英

Jmeter pass number of threads as dynamic value

I have a main thread where I am getting a list of categories from there I am passing each category from inside the ForEach Controller to next thread. In this thread I get a number of categories inside the variable

In the second thread I am going through each category and using ForEach Controller to pass each product into the 3rd Thread. In this thread I get a number of products inside the variable.

Now I want to use the above number of categories and products into the second and third threads as a dynamic variable ie if: categories are 10 then the second thread numbers should be 10 products are 100 then I would like 100/10 = 10 threads for 3 thread group.

I am using the interthread communication processors successfully which works fine withe static number of threads but not when I pass as a variable via interthread communication processors Please help me

在此处输入图片说明

  1. In first Thread Group define the desired number of threads using __setProperty() function like:

     ${__setProperty(threads,10, )} 
  2. In second Thread Group read the value using __P() function like:

     ${__P(threads,)} 

    在此处输入图片说明

  3. That's it, 2nd Thread Group will kick off as many threads as you define in the first one

    在此处输入图片说明

More information: Knit One Pearl Two: How to Use Variables in Different Thread Groups

Also be aware that s ince JMeter 3.1 you should be using JSR223 Test Elements and Groovy language for any form of scripting so convert your Beanshell test elements into JSR223 and make sure to use Groovy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM