JMeter use process and simple analysis monitoring

Source: Internet
Author: User
Tags jconsole

Recording JMeter scripts

There are two ways to record a jmeter script, one is to set up an agent, and the other is to use Badboy software, Badboy software to support the export of JMX scripts.

Here we introduce the second method, use Badboy to record the script, and then export the JMX files required by JMeter.

First, enter the address of the script to be recorded in the Address bar, then click the Green button to start recording (the red button in the toolbar can also be clicked for recording), click the Square Black button next to the Red round button to end the script recording (if you used LoadRunner, the steps are the same), Use the inline browser to manipulate the action you need to test, and it will record your related actions.

Then click on the Black button to record, we can export the Jmx file:

Save as "login developer. Jmx".

Iii. start testing with JMeter 1. Open script

Use JMeter to open the file we saved above.

After opening:

2. Modify script A, thread group

In the test plan, select Add to see both the thread group.

Such as:

Name: Can be arbitrarily taken, we keep creating a name that is automatically assigned

Note: Feel free to

Action to be performed after the sampler error: We choose to continue, after the error continues execution

Number of threads: generally we use to indicate how many users, that is, the number of users we test

Ramp-up Period (in Seconds): Indicates the delay time per user initiated, the above I set to 1 seconds, indicating that the system will start 1 seconds before the end of the 1000 users I set, if set to 1000 seconds, then the system will start 1000 seconds before the end of the 1000 users, The delay for the start user is 1 seconds, and if I set it to 0 seconds, all users are started immediately.

Number of cycles: if you want to limit the number of cycles to 10 times, you can cancel the last tick, and then fill in the text box in the following 10; Here we tick forever, indicating that if you do not stop or the time limit will continue to execute, it is to facilitate the dispatch of the call.

Scheduler configuration: This panel will appear when we tick the scheduler

Start time: Indicates the time when we start the script, when you do not want to start the script test immediately, but the time to start the script will not be next to the computer, you can set a startup time, and then run there click to start, the system will not run immediately, but will wait until you fill in the time to start running.

End time: Corresponds to the start time, indicating the time at which the script ended running.

Duration: Indicates how long the script is running, in seconds, such as if you want to allow users to log on continuously for 1 hours, you can fill in the text box 3600. If within 1 hours, the end time has arrived, it will overwrite the end time and continue execution.

Startup delay: Indicates the time when the script delayed startup, after clicking Start, if the start time has arrived, but there is no time to start the delay, then the startup delay will overwrite the start time, wait until the start delay time arrives, then run the system.

Note: If we need to use the scheduler to set the duration, if the number of threads is not enough until the end of the duration, we must tick the number of cycles to always, specifically, if there are other loops in the thread group, we also need to tick the number of cycles to always (as Step1 in the script I recorded above is also a loop , need to be always checked), otherwise, according to my configuration, will always remove the tick, the text filled 1, then regardless of the duration of the start time you set the end time and so on how much, the system runs 1000 times, will stop running again.

b, about HTTP requests

As for the HTTP request, we have recorded the script inside, here are some of the commonly used properties.

Click on the HTTP request and the following interface will appear:

which

Name: Can be arbitrarily taken, we can be named according to the path of the recording script

Note: You can make a brief introduction to the interface

Server name or IP: that is, the address of our server or IP, I am the project on this machine, so fill in localhost, you can fill in 127.0.0.1.

Port number: I use Tomcat, I set the port number to 8086 (tomcat default is 8080)

The timeout definition later can be used without filling in.

Implementation: This is the default when we record in Java

The agreement is filled with: http

Method is: GET

Content encoding: Encoding can be used without filling in

Path: That is, the path of the page, the following redirection and other options can be checked as needed, here we keep the recording does not change.

Parameters parameters: The parameters and files that are sent along with the path

The following proxy server can be ignored and filled out as required.

C, parameterization

As shown in the figure below, we parameterize the parameters sent by the request.

The above example is the login use case, login has two parameters: email and Developer_password, in the actual test, when we need to use different users to log in, we can use the parameterization.

1), we create a new file, here I created a txt file, named C.txt, the contents of

[Email protected],111111

[Email protected],111111

[email protected], 111111

2), select "Function Assistant dialog" in "Options" in JMeter, the following dialog will pop up:

which

CSV file to get values from | *alias: The path to the file to be read, the absolute path

CSV file Column number | Next| *alias: Start reading from the first column, note that number 0

As shown, we read the first user name in the C.txt (if you want to read the second column of the password, just change 0 to 1, and so on), click the "Generate" button to generate the function, we use the copy generated function string: ${__csvread (e:\c.txt,0)}.

Other functions are described later.

D. Assertion validation

In a Web test, sometimes even if we test the return of the response code is 200, there is no guarantee that the test is correct, at this time, we can use the response assertion, by comparing the content of the response to determine whether the returned page is we are determined to return the page.

Select the page we want to judge, click Add Assertion----response assertion, will appear as:

Name: Random, here we do not change

Note: Feel free to

Apply to: Here we choose the default value

Response field to test: Here we select the text of the response, which is the page information returned

Pattern matching rules: Here we choose to include, that is, whether the text of the response includes information we verify

Mode to test: developer name, that is, we need to verify that the developer name exists in the response text, or you can add more fields to verify.

Other assertions, such as file size and response time, are described later.

E, adding listeners

When we do performance testing, we often need a variety of data to verify our test results, JMeter also provides the relevant functions, here is the main report aggregate reports aggregation.

Click Add---Listener, select: View results tree, and aggregate report, if you need to see the assertion information can also choose the assertion results, will set everything after saving, then click Start, the system will run, the results will be displayed in the listener.

Iv. Analysis Results

1. View result tree

: The success is green and the failure is shown in red. If the result of the test is too many, you just need to see the wrong page, then tick "log error only"

2. Aggregated reports (Aggregate report)

which

#Samples: How many requests have been made in this scenario

Average: Average response time

Median: The median, which is 50% of the user's response time

90%line: Represents 90% of the user's response time, if the minimum and maximum difference is very large, we generally choose this as the final test results

Min: Minimum response time

Max: Maximum response time

error%: Error rate, number of requests that have failed in this test/total number of requests

Throughput: Throughput

Kb/sec: The amount of data received from the server side per second

Five, monitoring memory and CPU, etc.

Many times, we test performance needs to look at memory and CPU and other information to determine the system bottleneck, about the CPU and memory monitoring, jmeter is not very good support, many times, we can only through the system's resource Monitor to observe, a flash will not be recorded, very inconvenient. Fortunately, Google developed a special monitoring of the JMeter plug-in, make up for jmeter this aspect of the shortcomings, the following to introduce some of this plug-in--jmeterplugins, I am using 0.5.6 version.

1, the Jmeterplugins

Address: http://code.google.com/p/jmeter-plugins/downloads/list, select the desired version, download

2, Jmeterplugins the use of the configuration

Unzip the downloaded file and get the following directory:

Copy the Jmeterplugins.jar package to the JMeter's Lib directory under the Ext directory, restart the JMeter, we click Add to see a lot of [email protected] The beginning of the file.

Here we monitor the memory we are using: [email protected]-PerfMon Metrics Collectot

Before using, we need to run/serveragent/startagent.bat this file, we need to copy the ServerAgent directory and the following files to our test server, and then click Open (I am here, Open the application directly on this machine), its default port is 4444.

When everything is ready, click Start to get the following:

You can get the usual performance values you need when the system is running.

VI, monitoring memory and CPU (Jconsole)

Recently visited the forum, found a better monitoring of memory CPU and other gadgets, based on the principle of the more open source gadgets, record.

The steps to open this gadget are simple, if you have already configured the JMeter running environment, then you do not have to do other configuration, direct click: Start-"run-" input cmd--"and then enter" Jconsole "in the command line interface that appears to pop up a" Java Monitoring and Management console,

The following screen will appear:

Here we select the local process, and click on the Sun.tools.jconsole.JConsole line, and then click on the connection, you can see our memory and CPU usage.

Of course, we need information such as memory usage of the server, or we can select the remote process under the local process, enter the IP address of the server we need to test in the text box: port, then enter the username and password below, click Connect, see what happens.

JMeter use process and simple analysis monitoring

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.