DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • DataWeave: Play With Dates (Part 1)
  • Tired of Messy Code? Master the Art of Writing Clean Codebases
  • The Long Road to Java Virtual Threads
  • Exploring Exciting New Features in Java 17 With Examples

Trending

  • Why Database Migrations Take Months and How to Speed Them Up
  • How Can Developers Drive Innovation by Combining IoT and AI?
  • Comprehensive Guide to Property-Based Testing in Go: Principles and Implementation
  • How To Build Resilient Microservices Using Circuit Breakers and Retries: A Developer’s Guide To Surviving
  1. DZone
  2. Data Engineering
  3. Data
  4. Built-in JMeter Functions

Built-in JMeter Functions

Learn how to use built-in functions in JMeter for various helpful tasks in performance testing.

By 
Canberk Akduygu user avatar
Canberk Akduygu
·
Updated Nov. 08, 18 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
20.3K Views

Join the DZone community and get the full member experience.

Join For Free

JMeter allows you to conduct performance tests on your application by using any type of request. During these tests, we sometimes need to create new data, timestamps, or maybe manipulate a response.

For these purposes, JMeter provides built-in functions easily adaptable to your tests. Let’s explore the ones that you might need during a test.

Random Strings

There are a few different ways to create a random string in JMeter.

Examples:

 ${__RandomString(5)} will create a random string, It can be readable or not.

 ${__RandomString(5,ABCD123)} will create a random string containing only the alphanumeric values that you provide.

 ${__RandomString(5,,var)} will create a random string, then assign the value to a variable. You will be able to use that variable in another script by using the ${var} expression. The second parameter for the RandomString function is optional.

Random Numbers

There are a few different ways to create a random string in JMeter.

Examples:

 ${__Random(5)} will create a random number with a defined length.

 ${__Random(5,var)} will create a random number with a 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 number used to identify information in computer systems. In order to create one in JMeter, you should use the __UUID() functionality. UUID is almost unique as its length and random

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

Split Strings

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

Just create a BeanShell Processor where you want the split operation to happen. Then add  ${__split(${param},splitParam,|)} in the BeanShell script field.

1st Parameter: Parameter that you want to split.

2nd Parameter: After the split, split values will be assigned to this variable. You need to define an 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 the Time functionality to get the current time with different formats. You can specify a date/time format to format time values.

 ${__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 a timestamp like 1598723200239

There are many other functions that you would use with JMeter but in case those functions are not sufficient for you, JavaScript is here to help you.

JavaScript

You can use the __javaScript() function to pass any JavaScript code as a parameter, and do more extreme things, as well.

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)} 

Happy testing!

Strings Data Types

Published at DZone with permission of Canberk Akduygu. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • DataWeave: Play With Dates (Part 1)
  • Tired of Messy Code? Master the Art of Writing Clean Codebases
  • The Long Road to Java Virtual Threads
  • Exploring Exciting New Features in Java 17 With Examples

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!