Advanced performance testing JMeter

JMeter operating environment Description

JMeter is dependent on the Java runtime environment, so you must make sure that the machine has been installed JDK, you can use JMeter.

It should be noted: the best local version of the JDK 1.7 or later installed, the recommended JDK 1.8 version, otherwise it will not be compatible with downloaded from the official website of the latest down JMeter.

 

Express the require = var ( 'Express'); 
var = express.Router Router (); 
var = the require HTTP ( "HTTP-YKT-Client"); // middleware client parameters stored in req.bdoy inside 
/ * GET . Users Listing * / 
var COMM = the require ( 'www.feifanyule.cn/./public/js/constant.'); // this is the address of a server is defined inside 
var IP = comm.IP; 
const = comm.IP the IP ; 

router.get ( '/', function (REQ, RES, Next) { 
  res.send ( 'Resource the respond with A'); 
}); 
// Get channel 
router.post ( '/ aa', function (req, RES) { 
  http.post (IP www.yongshiyule178.com + 'AAAA', req.body) .then ((Data) => { 
    //console.log(JSON.stringify(data)) 
    res.send (Data) ; 
  }) 
});  
// this is the home to use interface
router.post ( '/ main', WWW.yigouyule2.cn  function (req, res) {
    http.post(IP+'/xhhms/rest/interfacesLoginController/getMenu', req.body ,req.headers).then((data) => {
      console.log(IP+'/www.chaoyueyule.com xhhms/rest/interfacesLoginController/getMenu');
        res.send(data);
    })
});

Copy the code

(1) JMeter download the official website address, click here.

(2) choose to download the latest version:

0sz3DWW.png

Please note that if download the latest version 3.3, it has been explicitly requested, JDK version must be 1.8. Click on the red box marked section under Binaries download.

(3) Upon completion of downloading on the Local self-built directory, decompress operations:

aJpi5NU.png

(4) configuration environment variable

New system variables: JMETER_HOME, the variable value: D: \ TestTool \ Jmeter \ apache-jmeter-3.1, as shown in FIG.

Configuration CLASSPATH (no words to create a new), the variable value:

%JMETERHOME%\lib\ext\ApacheJMetercore.jar;

%JMETER_HOME%\lib\jorphan.jar;

% JMETER_HOME% \ lib \ logkit-2.0.jar; if no other value, then the front should be added; these three jar must be configured in the CLASSPATH.

(5) JMeter start

Start Windows systems: Start jmeter.bat in the bin directory; that is started successfully demonstrate the following interface:

Understanding of the operating element JMeter

We use an example to taste fresh to see how to complete a simple performance testing practices using JMeter.

Test background

(1) were tested for the blog site garden site.

(2) scenario is:

  • Threads: the number of virtual users.

  • Ramp-Up period(in seconds,即单位为秒):即为场景加载的策略,设置的虚拟用户数需要多长时间全部启动。如果线程数为 10,时间为 5,也就是说每秒启动 2(2 是线程数 10 除以 Ramp-Up period 而来)个线程。

  • 循环次数:每个线程发送请求的次数。如果线程数为 10,循环次数为 5,那么每个线程发送 5 次请求,总请求数为 10×5=50。

如果勾选了永远,那么所有线程会一直请求直到停止;不勾选永远默认。总的请求运行时间为 Ramp-Up period × 循环次数 = 5 × 5 = 25 秒。

(3)我们想要的指标为:响应时间、错误率以及平均响应时长。

测试基本流程

打开 JMeter 界面后,我们以 HTTP 请求为例开始实践性能测试,基本流程如下所示。

(1)单击“测试计划”|“添加”|“Threads(Users)”|“线程组”命令,如图所示:

2hhVzez.png

(2)单击“线程组”|“添加”|“Sampler”|“HTTP 请求”命令,如图所示:

ADqaUg6.png

对 HTTP 请求的主界面说明如下,下图为 HTTP 主界面:

5IpHdxn.png

  • 名称:原则上可以随意命名,但是最好采用一个有意义的名字,方便后续脚本管理;示例中命名为:博客园 HTTP 请求。

  • 注释:用户记录用户可读的注释信息,但在测试中无任何作用。

  • 服务器名称或 IP:HTTP 请求发送的目标服务器地址或 IP。本案例中服务器名称是:www.cnblogs.com。

  • 端口号:目标服务器的端口号,默认为80。

  • timeouts 超时定义可以不用填写。

  • 协议:向目标服务器发送 HTTP 请求时的协议,可以是 HTTP 或是 HTTPS,默认为 HTTP。

  • 方法:发送 HTTP 请求的方法,有 POST 或是 GET 等。

  • content encoding:内容的编码方式。

  • 路径:目标 URL 路径(不包含服务器地址和端口)。

  • 自动重定向:如果选中该选项,当发送 HTTP 请求后得到的响应是 302/301 时,JMeter 自动重定向到新的界面。

  • Use keep Alive——持久的长链接:如果选中该选项,JMeter 和目标服务器之间使用 Keep-aLive 方式进行 HTTP 通信,默认选中。

  • use multipart/from-data for HTTP POST:当发送 HTTP POST 请求时,使用 use multipart/from-data 方法发送,默认不选中。

  • 同请求一起发送参数:在请求中发送 URL 参数,对于带参数的 URL,JMeter 提供了一个简单的参数化方法,用户可以将 URL 中所有参数设置在本表中,表中的每一行是一个参数值对,一一对应。

  • 同请求一起发送文件:在请求中发送文件,通常 HTTP 文件上传行为可以通过这种方式进行模拟。

  • 从 HTML 文件获取所有有内含的资源:当该选项被选中时,JMeter 在发出 HTTP 请求并获得相应的 HTML 文件内容后,还对该 HTML 进行 Parse 并获取 HTML 中包含的所有资源(图片、Flash 等),默认不选中。

如果用户只希望获取页面中的特定资源,可以在下方的 Embedded URLs must matc件框中填入需要下载的特定资源表达式,这样,只有能匹配指定正则表达式的 URL 指向资源会被下载。

  • 用作监视器:此取样器被当成监视器,在 Monitor Results Listener 中可以直接看到基于该取样器的图形化统计信息,默认不选中。

  • Save reponse as MD5 hash?:选中该项,在执行时仅记录服务端响应数据的 MD5 值,而不记录完整的响应数据,在需要进行数据量非常大的测试时,建议选中该项以减少取样器记录响应数据的开销。

以上说的各项内容一般情况下都选择默认项即可,无需配置。本示例中只需要填写【服务器名称或 IP】即可。

(3) Click "blog Park HTTP request (ie HTTP request)" | "add" | "listener" | "View Results Tree" command, used to observe whether the request was successful:

w8en9KC.png

(4) Click "blog Park HTTP request (ie HTTP request)" | "add" | "listener" | "Aggregate Report" command is used to monitor test indicators:

jDaaM9N.png

(5) Run the script:

JmFkbCI.png

(6) View Results Tree:

It is found from the result tree, requests have all been successful.

(7) View Aggregate Report:

Its monitoring indicators are described below:

  • Label: HTTP request defined name.

  • Samples: represents the total number of requests issued by this test altogether.

  • Average: Average response length, by default is the average length of the response to a single Request, the Controller Transaction when used, may be in response to the average length of Transaction display units.

  • Median: median, i.e. 50% of the length of the user's response.

  • 90% line: 90% of the length of the user's response;

  • 95% line: 95% length of the user's response;

  • 99% line: 99% of the length of the user's response time.

  • Min: the minimum length of time in response to access the page.

  • Max: maximum length in response to access the page.

  • Error%: the total number of requests error / requests.

  • Throughput: By default, represents the number of completed requests per second (Request per second), when using a Transaction Controller, Loadrunner may also represent a similar number of transaction per second.

  • Received KB / Sec: termination amount per data received from the server.



Guess you like

Origin blog.51cto.com/14529380/2435613