Thursday, March 20, 2014

Usage of _intSum and _longSum in JMeter

intSum:This is a built in function in Jmeter which helps to add multiple arguments/integer Values.
Drawback It can only add two real numbers. For float(12.23, 43.22), it is going to show an error message.
Arguments:

First Argument - The First integer value/Jmeter Variable

Second Argument – The Second integer Value/Jmeter Variable

. . . Nth Argument – The Nth integer value/Jmeter Variable

Last Argument – A variable or a reference name which will store the value for the addition and can be reused later.

Scenario:If User wants to increment a counter value by 2 with each iteration.

{__intSum(${tj_counter},2,tj_counter)}

Explanation:

1)__intSum- function name

2)${tj_counter}- First argument

3)1- Second Argument

4)tj_counter- Last Argument is the Reference name where the addition value get stored.
FAQ:

Is the function __counter better than __intSum?Yes Of course. Even __intSum can be used to increment a number with each thread which is quite similar to __counter function. But __counter function starts the counter with 1 and increment it by 1 and with __intSum we can start it from any number and increment it by any value.

Is there any scenario we can think of?Yeah. It will be helpful while user input needs any addition of any numbers. In that case we can simply add two or multiple values and use the variable to reference it any filed we want to.

longSum:

A Jmeter built in function which will help to add multiple long values.
Drawback - It can not take Float Value as arguments.
Arguments:

First Argument - The First long value
Second Argument – The Second long Value
. . . Nth Argument – The Nth long value
Last Argument – A variable or a reference name which will store the value for the addition and can be reused later.

Scenario:If User wants to increment a certain value by a certain number(Say to match the session ID with each iteration.)

__longSum(${tj_sessionid},65345,tj_sessionid)}

Explanation:

1)__longSum- Function Name

2)${tj_sessionid}- First argument

3)65345- Second Argument

4)tj_sessionid- Last Argument is the variable name where the addition value get stored and can be reused later.

No comments: