如何在 jmeter 中使用 jsr 223 预处理器? [英] how to use jsr 223 preprocessor in jmeter?
问题描述
有人请帮助我如何使用 Jmeter
中的 jsr223
预处理器和一些 examples
编写脚本.
Someone please help me how to do scripting using jsr223
preprocessor in Jmeter
with some examples
.
任何获得相同教程
的最佳网站.
Any best site to get tutorial
for the same.
提前致谢
西乔
推荐答案
例如:
- 首先,您需要选择一种脚本语言.根据 JMeter 最佳实践,最好使用 Groovy
- 添加 HTTP Request 并放入
google.com
进入服务器名称或 IP" 将 JSR223 PreProcessor 添加为 HTTP 请求的子项,并将以下行放入脚本"区域:
- First of all you need to choose a scripting language. As per JMeter Best Practices it's better to use Groovy
- Add HTTP Request and put
google.com
into "Server Name or IP" Add JSR223 PreProcessor as a child of the HTTP Request and put the following line into "Script" area:
sampler.setDomain("example.com");
example.com
而不是 google.com
google.com
.
example.com
instead of google.com
google.com
via View Results Tree listener. 因此预处理器的目的是在请求之前做一些事情,以使系统以某种方式为请求或更改请求做好准备(例如,您有动态数量的参数或动态数量的文件要发送与请求并且不想对其进行硬编码).
So the purpose of PreProcessors is do something before request in order to make the system prepared for the request or change request somehow (for instance you have dynamic number of parameters or dynamic number of files to send with the request and don't want to hardcode it).
在上面的例子中 sampler
代表 HTTPSamplerProxy,有关可用的方法和字段,请参阅 JavaDoc.另请查看 Beanshell 与 JSR223 与 Java JMeter 脚本:您一直在等待的性能下降! 指南,了解有关 groovy 引擎安装和脚本最佳实践的详细信息.
In above example sampler
stands for HTTPSamplerProxy, see JavaDoc for available methods and fields. Also check out Beanshell vs JSR223 vs Java JMeter Scripting: The Performance-Off You've Been Waiting For! guide for details on groovy engine installation and scripting best practices.
这篇关于如何在 jmeter 中使用 jsr 223 预处理器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!