You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Guruprasad R <gu...@gmail.com> on 2016/07/14 09:56:40 UTC

ForEach loop iteration value

Hi,

I am using foreach controller and not really able to find the iteration
value of the loop.

Ex: The foreach might run for 10 iterations and if its current iteration
value is 5, how would i be able to extract the value 5??

Regards,
Guruprasad R

Re: ForEach loop iteration value

Posted by Deepak Shetty <sh...@gmail.com>.
>knowing that all the counter values would evaluate to the same number &
that's not intended.
http://jmeter.apache.org/usermanual/functions.html#__counter
*Multiple __counter function calls in the same iteration won't increment
the value further.  *

>Are you suggesting me to set a new counter using beanshell and use it??
Im not entirely sure I understand your question - If you want to track
which iteration you are in , in a ForEach Loop , (your original question )
the counter should suffice - if you want incremented numbers within the
same loop then possibly you could use something like intSum (add a fixed
value to the counter variable ) or like you say track it yourself using
beanshell

On Sun, Jul 17, 2016 at 4:48 AM, Guruprasad <gu...@gmail.com> wrote:

> I was actually using the __counter method in the samplers belonging to the
> same thread group without knowing that all the counter values would
> evaluate to the same number & that's not intended. Are you suggesting me to
> set a new counter using beanshell and use it??
>
> Regards
> Guruprasad R
>
> On ಜುಲೈ 16, 2016, at 12:13 ಪೂರ್ವಾಹ್ನ, Deepak Shetty <sh...@gmail.com>
> wrote:
>
> >> If I make use of counter function, I might have to use it at other
> places
> > as well in the same thread, which would hold the same value. That would
> not
> > result in forming proper requests at other places.
> > Im not sure what you mean - if you need the current value use the
> variable
> > name of the counter, if you want to increment the value use the function.
> >
> >> On Thu, Jul 14, 2016 at 9:45 PM, Guruprasad <gu...@gmail.com>
> wrote:
> >>
> >> Right.. My request body needs the iteration count.
> >> If I make use of counter function, I might have to use it at other
> places
> >> as well in the same thread, which would hold the same value. That would
> not
> >> result in forming proper requests at other places.
> >>
> >> Finally using while loop instead of foreach.. Thanks for your help..
> >>
> >> Regards,
> >> Guruprasad
> >>
> >>> On ಜುಲೈ 15, 2016, at 02:49 ಪೂರ್ವಾಹ್ನ, Deepak Shetty <shettyd@gmail.com
> >
> >> wrote:
> >>>
> >>> hi
> >>> you probably need to add
> >>> http://jmeter.apache.org/usermanual/functions.html#__counter if you
> >> want to
> >>> know which iteration you are on.
> >>> However the for each is generally meant for situations where you dont
> >> need
> >>> to know the iteration value
> >>>
> >>> On Thu, Jul 14, 2016 at 2:56 AM, Guruprasad R <gu...@gmail.com>
> >>> wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>> I am using foreach controller and not really able to find the
> iteration
> >>>> value of the loop.
> >>>>
> >>>> Ex: The foreach might run for 10 iterations and if its current
> iteration
> >>>> value is 5, how would i be able to extract the value 5??
> >>>>
> >>>> Regards,
> >>>> Guruprasad R
> >>>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> >> For additional commands, e-mail: user-help@jmeter.apache.org
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>

Re: ForEach loop iteration value

Posted by Guruprasad <gu...@gmail.com>.
I was actually using the __counter method in the samplers belonging to the same thread group without knowing that all the counter values would evaluate to the same number & that's not intended. Are you suggesting me to set a new counter using beanshell and use it??

Regards
Guruprasad R

On ಜುಲೈ 16, 2016, at 12:13 ಪೂರ್ವಾಹ್ನ, Deepak Shetty <sh...@gmail.com> wrote:

>> If I make use of counter function, I might have to use it at other places
> as well in the same thread, which would hold the same value. That would not
> result in forming proper requests at other places.
> Im not sure what you mean - if you need the current value use the variable
> name of the counter, if you want to increment the value use the function.
> 
>> On Thu, Jul 14, 2016 at 9:45 PM, Guruprasad <gu...@gmail.com> wrote:
>> 
>> Right.. My request body needs the iteration count.
>> If I make use of counter function, I might have to use it at other places
>> as well in the same thread, which would hold the same value. That would not
>> result in forming proper requests at other places.
>> 
>> Finally using while loop instead of foreach.. Thanks for your help..
>> 
>> Regards,
>> Guruprasad
>> 
>>> On ಜುಲೈ 15, 2016, at 02:49 ಪೂರ್ವಾಹ್ನ, Deepak Shetty <sh...@gmail.com>
>> wrote:
>>> 
>>> hi
>>> you probably need to add
>>> http://jmeter.apache.org/usermanual/functions.html#__counter if you
>> want to
>>> know which iteration you are on.
>>> However the for each is generally meant for situations where you dont
>> need
>>> to know the iteration value
>>> 
>>> On Thu, Jul 14, 2016 at 2:56 AM, Guruprasad R <gu...@gmail.com>
>>> wrote:
>>> 
>>>> Hi,
>>>> 
>>>> I am using foreach controller and not really able to find the iteration
>>>> value of the loop.
>>>> 
>>>> Ex: The foreach might run for 10 iterations and if its current iteration
>>>> value is 5, how would i be able to extract the value 5??
>>>> 
>>>> Regards,
>>>> Guruprasad R
>>>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
>> For additional commands, e-mail: user-help@jmeter.apache.org
>> 
>> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: ForEach loop iteration value

Posted by Deepak Shetty <sh...@gmail.com>.
>If I make use of counter function, I might have to use it at other places
as well in the same thread, which would hold the same value. That would not
result in forming proper requests at other places.
Im not sure what you mean - if you need the current value use the variable
name of the counter, if you want to increment the value use the function.

On Thu, Jul 14, 2016 at 9:45 PM, Guruprasad <gu...@gmail.com> wrote:

> Right.. My request body needs the iteration count.
> If I make use of counter function, I might have to use it at other places
> as well in the same thread, which would hold the same value. That would not
> result in forming proper requests at other places.
>
> Finally using while loop instead of foreach.. Thanks for your help..
>
> Regards,
> Guruprasad
>
> > On ಜುಲೈ 15, 2016, at 02:49 ಪೂರ್ವಾಹ್ನ, Deepak Shetty <sh...@gmail.com>
> wrote:
> >
> > hi
> > you probably need to add
> > http://jmeter.apache.org/usermanual/functions.html#__counter if you
> want to
> > know which iteration you are on.
> > However the for each is generally meant for situations where you dont
> need
> > to know the iteration value
> >
> > On Thu, Jul 14, 2016 at 2:56 AM, Guruprasad R <gu...@gmail.com>
> > wrote:
> >
> >> Hi,
> >>
> >> I am using foreach controller and not really able to find the iteration
> >> value of the loop.
> >>
> >> Ex: The foreach might run for 10 iterations and if its current iteration
> >> value is 5, how would i be able to extract the value 5??
> >>
> >> Regards,
> >> Guruprasad R
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
> For additional commands, e-mail: user-help@jmeter.apache.org
>
>

Re: ForEach loop iteration value

Posted by Guruprasad <gu...@gmail.com>.
Right.. My request body needs the iteration count.
If I make use of counter function, I might have to use it at other places as well in the same thread, which would hold the same value. That would not result in forming proper requests at other places.

Finally using while loop instead of foreach.. Thanks for your help..

Regards,
Guruprasad

> On ಜುಲೈ 15, 2016, at 02:49 ಪೂರ್ವಾಹ್ನ, Deepak Shetty <sh...@gmail.com> wrote:
> 
> hi
> you probably need to add
> http://jmeter.apache.org/usermanual/functions.html#__counter if you want to
> know which iteration you are on.
> However the for each is generally meant for situations where you dont need
> to know the iteration value
> 
> On Thu, Jul 14, 2016 at 2:56 AM, Guruprasad R <gu...@gmail.com>
> wrote:
> 
>> Hi,
>> 
>> I am using foreach controller and not really able to find the iteration
>> value of the loop.
>> 
>> Ex: The foreach might run for 10 iterations and if its current iteration
>> value is 5, how would i be able to extract the value 5??
>> 
>> Regards,
>> Guruprasad R
>> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Re: ForEach loop iteration value

Posted by Deepak Shetty <sh...@gmail.com>.
hi
you probably need to add
http://jmeter.apache.org/usermanual/functions.html#__counter if you want to
know which iteration you are on.
However the for each is generally meant for situations where you dont need
to know the iteration value

On Thu, Jul 14, 2016 at 2:56 AM, Guruprasad R <gu...@gmail.com>
wrote:

> Hi,
>
> I am using foreach controller and not really able to find the iteration
> value of the loop.
>
> Ex: The foreach might run for 10 iterations and if its current iteration
> value is 5, how would i be able to extract the value 5??
>
> Regards,
> Guruprasad R
>