Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

A Quick start for JMeter, an Open Source performance testing tool (2)

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Catalogue

A brief introduction to JMeter

II. Introduction of JMeter function

III. JMeter script

4. Tips on JMeter

III. JMeter script

1. Test plan

The test plan is the starting point for JMeter testing and the container for other JMeter test components. Each test scenario / script is called a test plan.

(1) name; name related to business

(2) Notes: not required

(3) user-defined variables can be referenced directly with ${variable name}, where the variables are global variables that act on the entire test plan.

(4) run each thread group independently: unchecked by default, that is, all thread groups start concurrently. Check to execute all thread groups sequentially.

(5)

After the thread is finished running, stop the main thread.

(6) function test mode: unchecked by default. Check the box to record detailed requests, increase resource consumption and affect client performance.

(7)

Add directories and JAR packages to the classpath (% JMeterHOME%\ lib).

2.VUser and scene Design

The scenario design and Vuser of JMeter are designed under thread groups.

Here thread-> Vuser (number of concurrent users)

Number of cycles and scheduler-- > scene design module

(1) Thread attributes:

Number of threads

Ramp-Up Period: the time interval between threads

Number of cycles: the number of times the request is repeated.

Delay thread Creation until needed: delay the creation of threads until they are created when needed.

(2) dispatcher

Duration: test plan duration, which will override the end time

Startup delay: how long the test plan is delayed to start will overwrite the startup time.

3. Script recording using Badboy

Badboy recording is simple and does not require the use of proxies, but it cannot record URL-related static files and dwr requests like JMeter proxy.

After the recording is completed, export to JMeter format, and then directly open the script in JMeter can be used.

4. Parameterization

(1) use "user-defined variables" in the test plan

Add a parameter, then find the script that needs parameterization, and change its value to: ${key}

(2) use the built-in random function

There are function helpers in JMeter and several built-in functions that can be parameterized with related functions.

Method: open the function assistant, fill in the min,max, the function name, click "generate", and copy the generated random function to the place where parameterization is needed.

5. Association

The association of JMeter is based on regularization and Xpath Extractor.

(1) name, comment and Apply to are fine by default.

(2) the response field to be checked: indicates where to extract the regular expression. You can generally select Body.

(3) reference name: the variable name of the extracted value is referenced elsewhere. The reference method is ${variable name}.

(4) regular expression, extracted regular expression body

(5) template, referenced with $$, the extraction pattern of the regular expression, the value starts from 1, and the value 0 corresponds to the entire matching expression.

(6) default value. If no matching value is returned in the result, the value of the variable is the default value.

6. Checkpoint

JMeter checkpoints are implemented with assertions, and response assertions are more commonly used. After adding the assertion below, you need to add the "assertion result" to the appropriate listener to check whether the assertion result is correct after execution.

(1) default of name, comment and Apply to

(2) the response field to be tested can be either text or code.

(3) pattern matching rules:

Match: need to achieve exact match

Equals: the returned result is the same as the specified result

SubString: the returned result is a substring of the specified result

No: no match

(4) for the mode to be tested, if multiple assertion results are set, all the results need to be passed before they succeed, otherwise they fail.

7. Thinking time

The think time of JMeter is implemented with a timer. By default, there is no interval for JMeter to send requests. Intervals are added to simulate user requests more realistically, while reducing server pressure. No matter where the timer is placed, it will be executed before the Sampler. If you need to pause at a certain location, you can join the Test Action.

The scope of the timer, if you add multiple timers under the thread group, it will accumulate all the Sampler in the thread group, and you can add timers in a separate Sampler.

8. Gathering point

Synchronizing Timer is used to realize the function of rendezvous point in JMeter to simulate multi-user concurrent testing.

Indicates how many users there are at the rendezvous point before concurrency starts, and JMeter stops when the last batch of threads is found to be insufficient in use.

9. Result analysis

When running a performance scenario, turning on multiple listeners consumes resources. Commonly used are aggregate reports, graphical results, monitor results, and so on.

4. Tips on JMeter

1. Minimize the use of listeners

two。 Try to put similar Sampler in a loop and use variables to modify these Sampler instead of repeatedly adding Sampler

3. Do not use function test mode

4. Output the results in CSV format, not in XML format as much as possible

5. Save only the data results you need

6. It is best to use assertions when debugging scripts and disable assertions when running scripts, which is conducive to accurate test results

7. Viewing the result tree and viewing the result listener with a table are best used when debugging scripts, not during load testing

8. If you need to test a large amount of data, you can prepare the test Data in advance and put it in the data file to avoid wasting resources.

9. For load testing with large concurrency, try to run multiple non-GUI JMeter instances on multiple machines for distributed testing.

10. If insufficient memory is reported during testing, you can find jmeter.bat in the bin directory of jmeter to modify the JVM memory settings, such as: HEAP= "- Xms512m-Xmx512m". This can reduce the performance overhead caused by frequent applications to create and destroy memory.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report