# Built-in JMeter Functions

JMeter allows you to conduct [performance tests](https://loadium.com/blog/in-depth-analysis-throughput-controller-in-jmeter-and-splitting-threads-to-requests/) on your application by using any type of request. During these tests, we sometimes need to create new data, timestamp or maybe manipulate a response.

For these purposes, [JMeter](https://loadium.com/blog/handling-error-messages-of-jmeter-tests-in-loadium/) provides built-in functions easily adaptable to your tests. Let’s explore the ones that you might need during a test.

## Random String

In order to create a random string in [JMeter](https://loadium.com/blog/local-network-simulation-on-jmeter/) there are a few different ways.

Examples:

**${\_\_RandomString(5)}** This will create a random string, It can be readable or not.

**${\_\_RandomString(5,ABCD123)}** This will create a random string containing only the alphanumeric values that you provide.

**${\_\_RandomString(5,,var)}** This will create a random string, then assign the value to a variable. So you will be able to use that variable in another script by using ${var} expression. Second parameter for RandomString function is optional.

## Random Number

In order to create a random string in [JMeter](https://loadium.com/blog/jmeter-timers/) there are a few different ways.

Examples:

**${\_\_Random(5)}** This will create a random number with defined length.

**${\_\_Random(5,var)}** This will create a random number with defined length, then assign the value to a variable. So you will be able to use that variable in another script by using ${var} expression.

## UUID

A **universally unique identifier** (**UUID**) is a [128-bit](https://en.wikipedia.org/wiki/128-bit) number used to identify information in computer systems. In order to create one in JMeter, you should us \_\_UUID() functionality. UUID is almost unique as its length and random

**${UUID()}**  and you will have a value like that 0c7dba7e-7587-46d0-88f2-dfe577b88432

## Split String

In case you need to split a String with a delimiter, you can use ${SPLIT()} functionality.

Just create a BeanShell Processor where you would want the split operation to happen. Then add this **${\_\_split(${param},splitParam,|)}** in the beanshell script field.

1st Parameter: Parameter that you would want to split.

2nd Parameter: After the split, splitted values will be assigned to this variable. You need to define index when using it.

3rd Parameter: Delimiter that you have in the String.

Example:

Param = canberk|akduygu|loadium

splitParam\_1 = canberk

splitParam\_2 = akduygu

splitParam\_3 = loadium

## Time

You can use Time functionality to get current time with different formats. You can specify a date time format to format time value.

${\_\_time(dd/MM/yyyy,)} will get you 02/12/2018

${\_\_time(dd-mmm-yyyy hh:mm,)} will get you 02-12-2018 12:22

${\_\_time()} will get you the timestamp like 1598723200239

There are many other functions that you would use with [JMeter](https://loadium.com/blog/tag/jmeter/) but in case those functions are not sufficient for you, [JavaScript](https://loadium.com/blog/handling-error-messages-of-jmeter-tests-in-loadium/) is here to help you.

## JavaScript

You can use \_\_javaScript() function and pass any javascript code as a parameter and do extreme stuff also.

**Examples:**

Create a number between 0-10

**${\_\_javaScript(Math.floor(Math.random() \* 10))}**

Compare a variable to a hardcoded string then storing true/false result to a variable.

**${\_\_javaScript(“${username}”==”canberk”,found)}**
