Codeshang Education Python full-stack automation VIP course benchmarks against the standards of large manufacturers (challenging annual salary of 400,000)

content

1 Introduction

2. Preview timer

4. Detailed explanation of common timers

5. The scope of the timer

6. Summary


1 Introduction

  When the user actually operates, it is not a continuous click, but there are many pauses. For example, the user needs time to read the text content, fill in the form, or find the correct link. In order to simulate the actual user situation, we need to consider think time in performance testing. Failure to take thinking time into consideration can distort test results. For example, the estimated number of users that can be supported is too small. In performance testing, the pause time between access requests is called think time, so how to simulate this pause? We can achieve this with the help of JMeter's timers.

  Timers in JMeter are generally used by us to set delay and synchronization. The execution priority of the timer is higher than that of the Sampler (sampler). When there are multiple timers in the same scope (for example, under the controller), each timer will be executed. Once the sampler is valid, the timer can be added under the sampler node.

2. Preview timer

First, let's take a look at JMeter's timers, the path: thread group (user) -> add -> timer (Timer); we can clearly see that there are 9 timers in JMeter5, as shown in the following figure:

 

If you can't see the above picture clearly, Brother Hong summed up a mind map, about the type of logic controller of JMeter5, as shown in the following figure:

 

Through the above understanding, we have a general understanding and understanding of the timer. Below, Brother Hong will share and explain some timers that are usually used in work to friends or children's shoes.

4. Detailed explanation of common timers

In this section, Brother Hong will explain the commonly used timers in detail from top to bottom .

4.1Constant Timer

A fixed timer, as everyone knows by name, is a fixed timer. It is mostly used to simulate thinking time. As the name suggests, the interval time between requests is a fixed value.

Role: Set the waiting time (in milliseconds) before each thread request through ThreadDelay. Note: Fixed timing has a scope. When placed under the thread group, the scope is that all requests will delay the time set by the fixer. If placed in a request, the scope is the delay time of a single request (commonly used).

1. Let's take a look at what this Constant Timer looks like. Path: Thread Group > Add > Timer > Fixed Timer , as shown in the following figure:

 

2. The key parameters are described as follows:

Name: name, can be set at will, or even empty;

Comments: Comments, can be set at will, can be empty;

Thread Delay (in milliseconds): The thread waiting time, in milliseconds.

Usage (scenario), a more realistic simulation of user scenarios, you need to set the waiting time, or wait for the time of the previous request before executing, giving the sampler time to think between;

4.1.1 Examples

Scenario application: In the performance test, the time is estimated according to the user operation, or it takes a while to load the data. PS: In the process of actually simulating user requests, flexibility will be lost, and mass use is not recommended

1. Create a new test plan, add 2 samplers under the thread group to visit the homepage of the blog garden and visit Du Niang, as shown in the following figure:

 

2. Then add a fixed timer and set the delay time to 3000ms, which is 3s, as shown in the following figure:

 

3. After the configuration is complete, click "Save", run JMeter, and view the table results (the sampler visits the homepage of the blog garden and the interval between visits to Duniang is 3s), as shown in the following figure:

 

4.2Uniform Random Timer

The unified (uniform) random timer also makes the thread pause for a random time, but strives to make the random time more uniform, and it will appear. Uniform random timer, as the name implies, the delay time it generates is a random value, and the probability of occurrence of each random value is equal. The total delay time is equal to a random delay time plus a fixed delay time, the user can set random delay time and fixed delay time.

Function: The delay time it generates is a random value, and the probability of each random value appearing is equal. The total delay time is equal to a random delay time plus a fixed delay time, the user can set random delay time and fixed delay time. The delay time of each thread is a random time pause that conforms to the standard normal distribution, then using this timer, the total delay = Gaussian distribution value (average 0.0 and standard deviation 1.0) * specified deviation value + fixed delay offset (Math. abs((this.random.nextGaussian() * offset value) + fixed delay offset))

Total delay time = random time in the specified range (each random value in the range is equal probability) + fixed delay time

1. Let's take a look at what this Uniform Random Timer looks like. Path: Thread Group > Add > Timer > Uniform Random Timer , as shown in the following figure:

 

2. The key parameters are described as follows:

Name: name, can be set at will, or even empty;

Comments: Comments, can be set at will, can be empty;

Random Delay Maximum: the maximum random delay time;

Constant Delay Offset: Fixed delay time.

4.2.1 Examples

1. Create a new test plan, add 2 samplers under the thread group to visit the homepage of the blog garden and visit Du Niang, as shown in the following figure:

 

 

2. Then add a unified random timer and set the delay time to 3s, as shown in the following figure:

 

3. After the configuration is complete, click "Save", run JMeter, and view the table results (the sampler accesses the homepage of the blog garden and visits Duniang at an interval of 4s = 1000ms + 3000ms), as shown in the following figure:

 

4.3Precise Throughput Timer

The accurate throughput timer, as the name suggests, controls the throughput. Similar to Constant Throughput Timer, but can control requests more precisely. The difference is that the Constant Throughput Timer is a timer based on the time (as many seconds as the request is sent); the Precise Throughput Timer is a timer based on the throughput (the request is sent when the amount is reached). That is, it can control the speed and number of requests.

1. Let's take a look at what this Precise Throughput Timer looks like. Path: Thread Group > Add > Timer > Accurate Throughput Timer , as shown in the following figure:

 

2. The key parameters are described as follows:

Name: name, can be set at will, or even empty;

Comments: Comments, can be set at will, can be empty;

Thread Delay: The sub-controller is ignored, that is, the sub-controller fails, and the alternate controller takes over.

Target Throught: target throughput

Throught Period: Indicates how long to send the number of requests specified by Target Throught (in seconds)

Test Druation: Specifies the test run time (in seconds)

Number of threads in the bath : used to set the rendezvous point and execute concurrently after the specified number of requests

4.3.1 Examples

1. Create a new test plan, add 2 samplers under the thread group (set the thread group to ensure enough time) to access the blog garden home page (disabled) and visit Du Niang, as shown in the following figure:

 

2. Then add the accurate throughput timer, set 10 throughputs, set 10s to start 10 requests, and set the running time to 20s, as shown in the following figure:

 

3. After the configuration is complete, click "Save", run JMeter, and view the table results (it took about 20 seconds to start 21 threads), as shown in the following figure:

 

4. Set the rendezvous point Set the rendezvous point to 10 in the Precise Throughput Timer, and other parameters remain unchanged, as shown in the following figure:

 

5. Set the number of threads in the Thread Group to 10, as shown in the following figure:

 

6. After the configuration is complete, click "Save", run JMeter, and view the table results (you can see that every 10 threads are 1 group and start at the same time.), as shown in the following figure:

 

4.4Constant Throughput Timer

Fixed throughput timer, this timer introduces a variable pause, calculated to make the total throughput (measured in poplars per minute) as close as possible to a given number. Of course, if the server can't handle it, or if other timers or time-consuming test primitives block it, the throughput will be lower. Although the timer is called a constant throughput timer, the throughput value is not necessarily constant. It can be defined in terms of variables or function calls, and the value can be changed during testing. This can be changed in a number of ways: Using a counter variable Using a __jexl3, __groovy function to provide a changing value Using a remote BeeShell server to change Jmeter properties Note that throughput values ​​should not be changed frequently during testing - It takes a while for the new value to take effect.

Function of constant throughput timer: control throughput (when online stress testing, avoid hundreds of thousands of throughputs affecting online performance, after adding this, it is safer, you can increase it bit by bit); press The specified throughput is executed in units of every minute. The calculation throughput is based on the execution delay of the last thread.

Scope: This timer is placed at the lower level of the request and only works on its upper level request

1. Let's take a look at what this Constant Throughput Timer looks like. Path: Thread Group > Add > Timer > Constant Throughput Timer , as shown in the following figure:

 

2. The key parameters are described as follows:

Name: name, can be set at will, or even empty;

Comments: Comments, can be set at will, can be empty;

Target throughput (in samples per minute): Target throughput. Note that here is the number of requests sent per minute, you can choose the thread that acts: the current thread, the current thread group, all thread groups, etc. The specific meanings are as follows:

this thread only: Sets the throughput of each thread. Total throughput = number of threads * this value.

all active threads in current thread group: Throughput is distributed to all active threads in the current thread group. Each thread will be delayed based on the last run time.

all active threads: The total throughput of all active threads allocated to all thread groups. Each thread will be delayed based on the last run time. In this case, each thread group needs a fixed throughput timer with the same settings. (uncommonly used)

all active threads in current thread group (shared): Same as above, but each thread is delayed based on the last run time of the threads in the group. Equivalent to queuing within a thread group group. (uncommonly used)

all active threads (shared): Same as above, but each thread is delayed based on the thread's last run time. Equivalent to queuing all thread groups as a whole. (uncommonly used)

4.4.1 Examples

1. Create a new test plan, add a sampler under the thread group to visit the blog garden home page (disabled), and visit Du Niang, as shown in the following figure:

 

2. Then add a constant throughput timer and set the target throughput to 300, as shown in the following figure:

 

3. After the configuration is complete, click "Save", run JMeter, and view jp@gc - Transactions per Second (The constant throughput timer is set to 300/minute, which is 5/second, so the maximum tps is 5, and the tps here are about 5, the description has exceeded 5 and can be added upwards), as shown in the following figure:

 

5. The scope of the timer

1. The timer is executed before each sampler (sampler), not after (regardless of whether the timer position is before or below the sampler); 2. When a sampler is executed before, all timers in the current scope will be Execute; 3. If you want the timer to only apply to one of the samplers, add the timer as a child node; 4. If you want to wait after the sampler is executed, you can use Test Action;

6. Summary

6.1 Install plugin management

1. Check the options before installation and do not see the plugin management, as shown in the following figure:

 

2. If you want to install a jmeter plug-in, go to the official website (http://jmeter-plugins.org) to download the plug-in installation package, but the page is always in the search state, as shown in the following figure:

 

3. Then Brother Hong found a plugin management tool address for downloading a jmeter: http://jmeter-plugins.org/get/

4. Copy the downloaded file to the directory under your JMeter root lib/extdirectory , as shown below:

 

5. Restart jmeter, and you can see that the plugin management tool has been successfully installed in the options, as shown in the following figure:

 

6. Check the plugin to be downloaded, click the Apply changes and restart JMeter button to complete

 

Installed Plugins: Used to view installed plugins and uninstall plugins via 取消勾选-应用操作

Available Plugins: Used to view and install available plugins, install plugins by checking the -Apply action (button Apply changes and restart JMeter on the lower right side)

Upgrades: for upgrading plugins

   Well, today's last article about timers is explained here. This article mainly introduces Constant Timer , Uniform Random Timer , Precise Throughput Timer and Constant Throughput Timer . Thank you for your patient reading and learning.

Guess you like

Origin blog.csdn.net/ZangKang1/article/details/124253242