JMeter – Response Data Extractors – Comparison

If you are using JMeter, You would have also used any of the below Post Processors to extract information from the Sampler response and use it for the subsequent request or response validation.

  1. CSS/JQuery Extractor
  2. JSON Path Extractor
  3. Regular Expression Extractor
  4. XPath Extractor

But do they all perform same? How do they affect the JMeter test performance? Lets see in this article.

Note: Aim of this post not to teach how to use these extractors. My aim here is just let you know that how much time these extractors take to fetch specific data. I assume that you have some knowledge on these using extractors.

Test Plan:

To compare these post processors, I need to create a very simple test plan with no external dependency for accurate results.

The Test plan is as given below.

  1. Thread Group
  2. Dummy Sampler

simple-test-plan

I use a dummy XML as the Response Data (Taken from http://www.w3schools.com/xml/cd_catalog.xml)

simple-test-plan1

Latency & Response Time simulation are all turned off. No timers are included.

The Test Setup is as given below.

test-setup

Response Data:

Below XML is going to be our Response Data.

xml

What to extract:

I am trying to extract all the values of TITLE tag from the above XML by using different extractors.

Empire Burlesque
Hide your heart
Greatest Hits
..etc

Basically the testplan is exactly same. Only difference is going to be the type of extractor being used to extract the TITLE values from the response.

So, I create 5 identical tests.

tests

  1. css.jmx -> Test plan with CSS/JQuery Extractor.
  2. json.jmx -> Test plan with JSON Path Extractor – Response data has the CD Catalog xml in JSON format.
  3. nopost.jmx -> Test plan with no Post Processors.
  4. regex.jmx -> Test plan with Regular Expression Extractor.
  5. xpath.jmx -> Test plan with XPath Extractor.

 

Everything is ready now!! Lets run the tests in Non-GUI mode one-by-one. (I ensured that all the applications were closed before running).

Test Results:

I ran the same test 5 times and took the average. The results are as given below.

Test Plan Name Count Rate (/s)
CSS/JQuery Extractor 569288 9482.4
JSON Path Extractor 1353122 22533.6
Regular Expression Extractor 2051809 34176.9
XPath Extractor 288726 4809
No Extractor Included 9037481 150471.7

 

Conclusion:

When we look at the Count (no of samples sent in 60 seconds) and Rate (throughput) from the above table for the tests we did, It is obvious that these extractors clearly affect the performance of my test. When i do not have any post processor, I was able to make more than 9 Million requests within 60 seconds. But when we add a post processor to process the response data, as these post processors utilize CPU and Memory, they affect the test performance.

If we rank all these extractors based on their performance,

  1. Regular Expression Extractor
  2. JSON Path Extractor
  3. CSS/JQuery Extractor
  4. XPath Extractor

Regular Expression Extractor seems to perform much much faster compared to other post processors we compared with. XPath Extractor performs very poorly. It kind of makes sense as it needs to build a XML DOM from the response String and it needs to traverse it to find all the TITLE tags.

We also can not come up with our test plan without an response data processor. Of course we need them. But, what I am trying to convey here is – Be cautious of these Response Data extractors. Think twice before adding an XPath Extractor to your test plan.  Always use Regular Expression Extractor if possible as it takes less memory and CPU.

 

Happy Testing 🙂

 

 

Share This:

1 thought on “JMeter – Response Data Extractors – Comparison

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.