Andrey Pokhilko is Chief Scientist at BlazeMeter. Andrey is a renowned thought-leader and innovator within the Apache JMeter performance testing community. He has worked extensively to create and develop tools that enhance the Apache JMeter protocol coverage and analytical reporting capabilities. In 2009, he founded and led this open source project to its undisputed status as the premier source of JMeter Plugins in the world. Loadosophia was similarly born from Andrey’s desire to complete JMeter’s offerings. He has world-class experience with large scale performance testing, having led the load testing team for five years at search engine giant Yandex.

Become a JMeter and Continuous Testing Pro

Start Learning

Test Your Website Performance NOW! |

arrowPlease enter a URL with http(s)
Feb 22 2016

How to Cut Your JMeter Scripting Time by 80%

Creating test scripts is one of the biggest headaches in load testing today! We know that the scripts need to be as realistic as possible, but this is easier said than done. Due to the dynamic nature of modern web applications, complex logics that are easily performed on browsers are much harder to simulate with JMeter.


This means you can end up spending several hours or even several days creating a JMeter script for your web application. This time is normally spent trying to reverse-engineer the dynamic parameterization (correlation) of the website.


Right now, you’re probably using one of two methods to create your JMeter script :


1. Write a Script Manually From Scratch


The Pros of This Approach:

You’ll get a perfectly structured JMX, with all the required Configuration Items in place, and requests correctly grouped under the Simple/Transaction Controllers. More importantly, it will have all the Extractors that handle the transfer of parameters from one page to another, producing a parameterized script that can be executed against dynamic websites. It is clean and doesn’t have items unrelated to the original purpose of the script.


The Cons:

To create this script, you’ll need to have a perfect understanding of how web browsers and servers work, and be able to read HTTP protocols, its headers, requests, and responses.


2. Record Your Script With a Recording Proxy or Browser Plugin


The Pros of This Approach:

This method is initially much faster and easier than the first. Instead of writing a script from scratch, you only have to setup the proxy and configure the browser.



The Cons:

Your JMX file will be unstructured; all the requests will be on the same level and there will be no extractors. For real-life web-applications, this “raw” JMX requires a lot of additional work to parameterize it and make it operational. You’ll spend most of your time tracking which page each dynamic value originates from. All these investigations could take you longer than just writing a script from scratch.


So right now you can either write a manual script from scratch - which takes hours or even days. Or you can record a script and spend even longer digging into the script.


Luckily there is new way which resolves all of these issues - and it’s totally free!


Automating Your JMeter Scripting with the SmartJMX


The “SmartJMX” combines all the advantages of a manual script with the ease of browser proxy recording.


Here’s how you use it:


Go to BlazeMeter’s Proxy Recorder

The “SmartJMX” is a feature within the Proxy Recorder - which can be accessed from the BlazeMeter application. It’s completely free of charge, even for BlazeMeter’s free-tier users.


If you’re not already familiar with the Proxy Recorder, please take a look at our JMeter Video Tutorial on setting up a proxy and starting your recording.


JMeter Scripting - BlazeMeter's Proxy Recorder



Click the SmartJMX button


The “SmartJMX” button is enabled shortly after you stop the recording:

JMeter Scripting - SmartJMX Button

This button gives you the JMX file. However, this is very different to the normal JMX button that provides simple script files from your recording.


How? Well, the Smart JMX file has three very important improvements - which make a huge difference to your script. These are:


1. Automatic Extractors

The most important thing here is the auto-parameterization (note: this might also be known as “auto-correlation”).


The SmartJMX tries to find the source of every URL, GET parameter, POST parameter, or JSON POST field. If it finds a candidate, it attaches the variable extractor to the corresponding sampler and uses the extracted variable instead of the constant value. If it finds several possible extractors, it lists all of them so you can choose the most appropriate one.


JMeter Scripting: Automatic Extractors



This means that you can have your VIEWSTATE or PHPSESSID automatically handled for you. You’ll be surprised by how many variables can be found. SmartJMX will even try to find timestamps and replace them with the  ${__time()} function.


All variables found through auto-parameterization will be listed with their default values under the top-level “Variables” Configuration Item. This allows us to view all used variables from one single place.


2. Requests Cleanup and Grouping


Just take a look at this typical JMX structure, taken from a regular (not smart) script generator:


JMeter Scripting: Typical JMX Structure


Now compare it with the SmartJMX version:


JMeter Scripting: SmartJMX Version


See the difference?


The SmartJMX is much cleaner because it aims to omit requests belonging to embedded resources on a page.  This lets you concentrate on the requests that form the main logic flow of the script. Based on the logical properties of the requests, it will then group them to present a meaningful set of request clusters.


3. Configuration Items


The SmartJMX adds some top-level Configuration Items into the JMX to make it more operable, including:


  1. The Cookie Manager - to support authentication persistence
  2. The configuration of top-level headers with the headers that are found in all requests
  3. HTTP request defaults with servers/ports/protocols for the most common addresses found in requests
  4. The top-level “View Results Tree” - so you can immediately start validating the test plan


The SmartJMX also adds the per-cluster and per-sampler headers’ configurations - along with the corresponding headers.


How Automating Scripts Can Impact Your Daily Working Life


Words can’t express the feeling of getting a JMX script written automatically for you!


It’s well worth trying this and just seeing how much time it saves. Pushing 80% of your routine tasks to an automated scripting solution will have an amazing impact on your productively. Instead of spending, say, three hours on scripting, you’ll spend just 36 minutes. This gives you at least an extra 2.5 hours to spend on improving the performance of your system or researching something cool like automated results analysis.  


Get Started Now


Learn how to record a user session with JMeter’s proxy server


Start recording and creating scenarios for your mobile app

Record a session with BlazeMeter’s Chrome Extension


Have any questions or comments? Please share in the comments box below.




arrowPlease enter a URL with http(s)

Interested in writing for our Blog?Send us a pitch!