Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMeter - loop controller with variable loop count

Tags:

loops

jmeter

I am using JMeter and I want to define one loop controller. In this loop I want to define the loop count with a Jmeter variable. Is this posible?

Thanks a lot

like image 878
user1582114 Avatar asked Aug 07 '12 13:08

user1582114


People also ask

What is loop count =- 1 in JMeter?

Definition of JMeter Loop Count. JMeter provides different types of functions to the user, in which that loop count is one of the functions that is provided by the JMeter. Basically, loop count means we can set the number of iterations for every user as per our requirement.

What is the use of counter in JMeter?

Counter element in JMeter allows a user to generate an incremental number that can be referenced anywhere in the Thread Group.

What is loop count in thread group?

Most people are aware of the fact that a thread simulates a user and loop-count means the number of times the thread will make request. Let's walk through the differences. In Scenario 1, 10 threads are used, and the ramp-up period is 10 seconds, so JMeter will take 10 seconds to get all 10 threads up and running.


2 Answers

I know is very late to help you, but it can help the others.

One good way to do this is to define a counter inside the loop controller.

Example, if you want a loop with 20 iterations, you put 20 in the loop controller and in the counter you put from 0 - 19. In the counter you can also define an increment. The output variable is named in the Reference Name field.

loop controller with counter

like image 97
Johnny Willer Avatar answered Oct 20 '22 17:10

Johnny Willer


Yes, it's possible.

Define your user variable using the User Defined Variables component, or use the CSV component.

Then, in the Loop Controller, define loop count to: ${nameOfVar}

Since version 4.0 of JMeter, there is an easier way:

  • https://jmeter.apache.org/usermanual/component_reference.html#Loop_Controller

JMeter will expose the looping index as a variable named

__jm__Name of your element__idx

So for example, if your Loop Controller is named LC, then you can access the looping index through ${__jm__LC__idx}. Index starts at 0

If you're looking to learn jmeter correctly, this book will help you.

like image 39
UBIK LOAD PACK Avatar answered Oct 20 '22 19:10

UBIK LOAD PACK