In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how Jmeter gets all the request messages in the jtl file". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "How does Jmeter get all the request messages in the jtl file"!
preface
As you know, Jmeter runs tests to generate jtl files that contain the request returns for the entire script and various settings. Recently encountered a problem to share with you, that is, as a performance test group, from the automation test group to get a bunch of jtl files, need to extract their own request messages.
Open the jtl file with Jmeter and you can see that the request message is an xml message, as shown in the following figure:
Change the jtl file to a txt file and open it as shown below:
Content or more, there are N requests, how should extract it, there are Java-based friends should be able to use the code to extract directly, I did not go to achieve, should not be very difficult. For those of us familiar with testing, how do we use jmeter tools to extract it?
Here's what I thought:
1. The original jtl file can only be seen in the request to view the result tree, but it is changed to use BeanShell to send the request, and all the results can be seen in the return of viewing the result tree.
2. In the view result tree, you can already see the response, the returned is all the original jtl file content, extract the message can use regular expression, boundary value extractor, get what you want, determine the right and left boundaries of the request, match the number to write-1, that is, you can get all the messages that meet the requirements.
Simply put, it is to change the suffix of jtl file to txt, write code in jmeter using beanshell sampler, read the file, and put the read result into Jmeter variable, and use debug sampler to see the result.
3. At this time to obtain data data, you can not simply use ${data}, can be regarded as a comprehensive result, you need to use the ForEach controller when obtaining, because multiple jtl can not determine how many requests need to be extracted, so the loop end field ${data_matchNr}.
4. The last step is to obtain variables and output them. Because the message in xml format was escaped when outputting before, a restore is done here. It can be implemented by using the fixed method in lang3 package. The code is as follows:
The final output txt file, separated by newlines, can be adjusted by itself, and then used for performance test script parameterization, as follows:
Jtl file more, to carry out path parameterization, put the entire script content in a thing controller, to prevent multi-threading, get different results, run the corresponding multi-thread processing can be set.
At this point, I believe that everyone has a deeper understanding of "how Jmeter gets all the request messages in the jtl file," so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.