Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMeter mathematical function

Tags:

I have one random variable and one variable which I read from page. How can I subtract or multiply that two variables and where or in which component in JMeter.

like image 393
Ballon Avatar asked Aug 12 '10 11:08

Ballon


People also ask

What are the functions of JMeter?

Functions can be used for many different operations, including: inputting information from a file, performing math calculations and value generation, processing strings, evaluating JMeter variables, working with JMeter properties and executing scripts like Javascript or BeanShell script.

What is the syntax of function in JMeter?

Syntax of a function in JMeter: Here "__functionName" matches the name of a function and Parentheses surround the parameters sent to the function. If a function parameter contains a comma then be sure to escape this with "\", otherwise JMeter will treat it as a parameter delimiter.

Which functions can be used in Test Plan in JMeter?

You can simplify your JMeter test plan by using functions to get parameters like the timestamp or thread name, perform complex calculations, add BeanShell or Javascript code, or read from data files without having to code from scratch.

Which functions Cannot be used with the Test Plan in JMeter?

JMeter thread variables will have not been fully set up when the functions are processed, so variable names passed as parameters will not be set up and variable references will not work. Hence, split() and regex() and the variable evaluation functions will not work.


2 Answers

Check out the functions page for Jmeter. It has tons of cool math tools that you can plug anywhere in your script.

You'll most likely end up doing a jexl command, which would look something like this: ${__jexl2(${var1}-${var2})}

like image 123
BlackGaff Avatar answered Oct 16 '22 05:10

BlackGaff


The above did not work for me. How ever i was able to resolve my problem with :

${__jexl(vars.get("YOUR_VARIABLE")+1)} 
like image 39
rinkush sharda Avatar answered Oct 16 '22 04:10

rinkush sharda