1. Some performance indicators in the JMeter
Throughput:: Throughput rate transactions per Second: Avg. Rps: Number of request per second = Total Request quantity/sec successful Hits per Seco Nd: Number of successful clicks per second Failed Hits per Second: Number of failed clicks/sec Successful Rounds: Successful request Failed Rounds: Failed request User connections: Number of user connections, that is, database connections number of deadlocks: Database deadlock Butter Cache Hit: Database Cache Hits of course, in the performance test, the server CPU utilization, memory usage, disk I/O and network I/O, and so on some server performance metrics is also very important.
2. Download and installation of JMeter
(1) Download and install the Java Development Environment (Installation of JDK and addition of environment variables)
(2) Download: http://jmeter.apache.org/download_jmeter.cgi
After decompression, click Apachejmeter.jar or Jmeter.bat in the Apache-jmeter bin file to run JMeter.
3. A simple example
(1) Add a "thread Group" and set the number of concurrent threads.
(2) Add an "HTTP Request" to "Thread Group".
(3) Add a "view Results tree" to observe the return result of the request.
(4) By constantly increasing the number of concurrent users, to analyze the site's "throughput" (throughput rate).
4. HTTP Cookie Manager
This manager can automatically manage cookies, such as if you request a site, and then his response set Cookie,cookie Manager automatically saves the cookies and uses the values of those cookies in all subsequent requests sent to the site. In addition, the manager also supports users to add cookies manually.
However, if you want to use this feature properly, you must edit the Jmeter.properties file in the Bin folder to add/modify it: cookiemanager.save.cookies=true
After editing is complete, it is best to restart JMeter.
5. JMeter's Webdriver Plugin
(1) Download jmeterplugins-webdriver: http://jmeter-plugins.org/downloads/all/
(2) Extract the Bin folder copy into the JMeter folder (merged with the JMeter Bin folder).
(3) Reboot the JMeter.
(4) Add Jp@gc-firefox Driver config and Jp@gc-web Driver sampler.
(5) Add Webdriver script in Jp@gc-web Driver sampler.
The following paragraph Webdriver script, after all, jmeter webdriver scripts and standards are still different:
var r = newjava.util.Random () var
pkg =javaimporter (org.openqa.selenium, Org.openqa.selenium.support.ui)
var wait = newpkg. Webdriverwait (Wds.browser)
WDS.browser.get (' http://www.portal2016.ef.com.br/riovolunteer/login/test/')
Wait.until (pkg. expectedconditions.presenceofelementlocated (pkg. By.xpath ("//input[@name = ' userName '])")
WDS.sampleResult.sampleStart ()
var userName = WDS.browser.findElement (pkg. By.xpath ("//input[@name = ' userName ']")
Username.sendkeys ("#########")
var password = WDS.browser.findElement (pkg. By.xpath ("//input[@name = ' password ']")
Password.sendkeys ("#########")
var login =wds.browser.findelement (Pkg. By.xpath ("//button[@type = ' submit ']")
Login.click () wait.until (pkg. expectedconditions.presenceofelementlocated (pkg. By.xpath ("//a[@class = ' et ']")
WDS.sampleResult.sampleEnd ()
6. JMeter's ServerAgent Plugin
(1) Download ServerAgent plugin: http://jmeter-plugins.org/downloads/all/
(2) Unzip the plugin on the server and perform it on the server: Startagent.bat--udp-port 0--tcp-port 3450
(3) Edit Jmeter.properties file, add: Jmeter.save.saveservice.thread_counts=true
(4) Download jmeterplugins-standard:http://jmeter-plugins.org/downloads/all/
(5) After the local decompression, the Lib folder is copy to the JMeter folder, and restart the jmeter.
(6) Add Listenal/jp@gc-perfmon Metrics Collector and add Metricparameter.
(7) Run the JMeter script so that you can monitor the performance of the server.
7. Assertion and Timer
Assertion is used to determine whether response data meets certain conditions, such as size greater than 50K. And a timer can let a thread delay a certain amount of time.
8. Parameterized
(1) Add "CSV Data Set Config"
Where recycle on EOF indicates whether to iterate over multiple rows of data; Variable names represents the user-defined column name for each column.
(2) In this way, the data can be obtained by ${host} and ${path} in JMeter.
9. JMeter Recording
The first method:
Download Badboy for recording: http://www.badboy.com.au/download/send?svId=118
The second method:
(1) Add "thread Group" and add "recording controller" under the thread group
(2) Add "HTTP proxy server"
Target controller: Test plan > Thread Group
Grouping: Putting a new controller in each group
PORT: 9999 (must ensure that the port is not occupied)
Exclusion mode:. *\. (BMP|CSS|GIF|ICO|JPE?G|PNG|SWF|WOFF|JS)
(3) in the "HTTP proxy server" click the "Start" button
(4) Open the browser and set the proxy: (You must ensure that the port number is the same as the port number of the HTTP proxy server)
(5) Enter the URL, do the desired operation.
(6) Click the "Stop" button in the "HTTP proxy server" to complete the recording.
JMeter Distributed Testing
The ability of a single computer to process threads is limited, and if a large number of threads are required (some think that a jmeter client thread should not exceed 100), then a jmeter distributed test is needed. The steps to generate the load using multiple machines are as follows:
(1) Install JMeter on all machines that expect to run jmeter as load generators, and identify one of the machines as controller, and the other machines as agents. Then run the Jmeter-server file on all agent machines (assuming that two machines 192.168.0.100 and 192.168.0.101 are used as agents)
(2) in the JMeter Bin directory of the controller machine, locate the Jmeter.properties file and edit the file:
Find: remote_hosts=127.0.0.1
Modified to: remote_hosts=192.168.0.100:1099,192.168.0.101:1099
In addition, the port number should be ensured that it is not occupied and the firewall is closed.
(3) Start the JMeter application on the controller machine, select the menu "Run"---> "remote boot" to start the agent separately, or simply select "Remote all Boot" to start all the agents.
JMeter's SQL Test
(1) Download Sqljdbc4.jar and copy to jmeter Lib folder
(2) Restart JMeter
(3) Add JDBC Connection Configuration and set:
Database Url:jdbc:sqlserver://jzf2013:1433;databasename=mytest
JDBC Driver Class:com.microsoft.sqlserver.jdbc.SQLServerDriver
Username:sa
Password: #####
(4) Add a JDBC Request and enter a representative SQL statement.
(5) Run and view the results.
Other types of databases are set as follows:
datebase |
Driver class |
Database URL |
Mysql |
Com.mysql.jdbc.Driver |
Jdbc:mysql://host:port/{dbname} |
PostgreSQL |
Org.postgresql.Driver |
Jdbc:postgresql:{dbname} |
Oracle |
Oracle.jdbc.driver.OracleDriver |
Jdbc:oracle:thin:user/pass@//host:port/service |
MSSQL |
Com.microsoft.sqlserver.jdbc.SQLServerDriver Or Net.sourceforge.jtds.jdbc.Driver |
Jdbc:sqlserver://ip:1433;databasename=dbname Or jdbc:jtds:sqlserver://localhost:1433/"+" library " |