jmeter pressure measurement practice

Skills for: command line execution

Command: Specifies the parameters, the report storage location

jmeter -n -t baidu_requests_results.jmx -r -l baidu_requests_results.jtl -e -o /home/resultReport

-n: non-GUI mode execution JMeter

-t: location and file name of the file where the test is performed

-r: remote start all agent used in a distributed test scenarios, not just a single point distributed test does not need -r

 -l: Specifies the generated test results to save the file, jtl file format

-e: After the test, generation of test reports

-o: specifies where the test reports

Precautions:

1, -o specified files and folders, must not exist, otherwise it will fail to perform, corresponding to the above command is resultReport folder must not exist otherwise an error

2, the end will only automatically generate test reports, force the end of execution does not generate test reports

 

Skills II: stepped pressure measurement

Concurrency Thread Group and Stepping Thread Group two types of threads are available for groups stepped pressurization test, but due Stepping Thread Group has not been officially recommended, we are introduced to Concurrency Thread Group.

 

target concurrency: concurrent goals

ramp up time (min): Acceleration Time

ramp-up steps count: count acceleration step

hold target rate time (min): retention time target speed

thread iterations limit: limit the number of iterations thread

log threads status into file: the thread state to a file

Above, graphically illustrates the process thread pressure.

 

Three techniques: control requests (QPS) pressure measurement

Arrivals Thread Group we can achieve the purpose of controlling the number of requests by the thread group

target rate: target rate, the number of requests per second

ramp up time (sec): time to reach the required target rate

ramp-up steps count:达到目标速率需要多少步

hold target rate time(sec):保持目标速率时间

thread iterations limit:线程迭代次数限制

log threads status into file:将线程状态记录到文件

concurrency limit:最大并发数限制

 

技巧四:权重控制压测

weighted switch controller 控制权重百分比的场景控件

 

技巧五:调试脚本添加Debug PostProcessor

一般是在需要添加正则(Regular Expression Extractor)、Xpath Extractor、 JSON Path Extractor等提取器的时候或者在参数化的时候,添加一个Debug PostProcessor,这样方便在调试脚本的时候,

看是否正确的提取到了所要的信息。当然,得添加View Result Tree,因为执行脚本以后是在tree里看debug的信息

 

技巧六:benshell使用

    JMeter在它的BeanShell中内置了变量,用户可以通过这些变量与JMeter进行交互,其中主要的变量及其使用方法如下:

  • log:写入信息到jmeber.log文件,使用方法:log.info(“This is log info!”);

  •  beanshell断言 Failure=true/false
  • ctx:该变量引用了当前线程的上下文,使用方法可参考:org.apache.jmeter.threads.JMeterContext

    ctx.getCurrentSampler(); 获取当前 sampler 请求

    ctx.getPreviousSampler(); 获取前一个 sampler 请求

    ctx.getThreadNum(); 获取当前线程的序号,从 0 开始计数

    ctx.getThread(); 获取当前线程

    ctx.getThreadGroup(); 获取当前线程组

    ctx.getProperties(); 获取所有属性

    ctx.getVariables(); 获取当前线程的所有变量

  • vars - (JMeterVariables):操作jmeter变量,这个变量实际引用了JMeter线程中的局部变量容器(本质上是Map),它是测试用例与BeanShell交互的桥梁,常用方法:

    a) vars.get(String key):从jmeter中获得变量值

    b) vars.put(String key,String value):数据存到jmeter变量中

    更多方法可参考:org.apache.jmeter.threads.JMeterVariables

  • props - (JMeterProperties - class java.util.Properties):操作jmeter属性,该变量引用了JMeter的配置信息,可以获取Jmeter的属性,它的使用方法与vars类似,但是只能put进去String类型的值,而不能是一个对象。对应于java.util.Properties。 

    a) props.get("START.HMS");  注:START.HMS为属性名,在文件jmeter.properties中定义 

    b) props.put("PROP1","1234"); 

  • prev - (SampleResult):获取前面的sample返回的信息,常用方法:

    a) getResponseDataAsString():获取响应信息

    b) getResponseCode() :获取响应code

Guess you like

Origin www.cnblogs.com/unknows/p/10954737.html