Jmeter. BeanShell后处理器 [英] Jmeter. BeanShell PostProcessor

查看:531
本文介绍了Jmeter. BeanShell后处理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在jmeter中完成了bean shell脚本的编写,但是我没有找到 任何例子,它在jmeter中如何有用以及以哪种方式.意思是阅读 采样器值等 谁能用示例解释Jmeter中的bean shell脚本. beanshell后/预处理器脚本,我们在其中编写脚本. 我正在努力使用它的实际用途.请解释 这样做对我或其他人以及理解都将大有帮助 的用途.

I have gone through the bean shell scripting in jmeter but i did not find any example of that, how it is useful in jmeter and which way.means reading the sampler values etc. Can any one explain bean shell scripting in Jmeter with example.In beanshell post/pre processor script where we write the script. I am struggling with this what is the actual usage of it .Please explain with this .it would be great help for me or others as well for understanding the usage of it.

推荐答案

如果查看Beanshell Post Processor的脚本"部分,您将看到以下内容:

If you look into "Script" section of Beanshell Post Processor you'll see the following:

Script(variables: ctx, vars, props, prev, data, log)

  • ctx-代表 JMeterContext ,提供对JMeter的访问上下文API(有关详细信息,请参见JavaDoc).用法示例:

    • ctx - stands for JMeterContext, provides access to JMeter Context API (see JavaDoc for details). Example usage:

      int threadNum = ctx.getThreadNum(); // get current thread number 
      

    • vars-代表 JMeterVariables .使用vars可以获取/设置变量值.

    • vars - stands for JMeterVariables. Using vars you can get/set variable values.

      String myvar = vars.get("myvar"); // get ${myvar} variable value and store it to myvar string 
      myvar = myvar + "something"; // append "something" to myvar
      vars.put("myvar", myvar); // put new value into ${myvar} variable
      

    • props-代表JMeter Properties.与变量基本相同,但是变量的可见性仅限于当前线程组,并且属性是全局"

    • props - stands for JMeter Properties. Basically the same as variables, but variables visibility is limited to current thread group only and properties are "global"

      上一个-上一个 SampleResult 的简写.似乎正是您要寻找的.您可以获取/设置开始时间,结束时间,执行时间,延迟,URL,响应代码,响应消息等.有关详细信息,请参见JavaDoc.用法示例:

      prev - shorthand to previous SampleResult. Seems to be exactly what you're looking for. You can get/set start time, end time, execution time, latency, URL, response code, response message, etc. See JavaDoc for comprehensive information. Example usage:

      String code = prev.getResponseCode(); 
      String message = prev.getResponseMessage();
      

    • data-包含父采样器响应数据的字节数组

    • data - byte array containing parent sampler response data

      String samplerData = new String(data);
      System.out.println(samplerData);
      

    • log-可用于将某些内容打印到jmeter.log文件

    • log - can be used to print something to jmeter.log file

      log.info("This line has been written by Beanshell Post Processor");
      

    • 有关更多信息,请参见如何使用BeanShell:JMeter最喜欢的内置组件指南细节和实际示例.

      See How to use BeanShell: JMeter's favorite built-in component guide for more details and real-life examples.

      这篇关于Jmeter. BeanShell后处理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆