前言
结合之前一篇介绍JMeter测试Kafka的文章,遇到了JSR223,Beanshell等概念,这篇文章有讲解,转帖出来。
正文
Beanshell vs JSR223 vs Java JMeter Scripting: The Performance-Off You've Been Waiting For!
There are several options to perform custom JMeter scripting and extend baseline JMeter functionality. Check out the most popular extension mechanisms, compare performance and analyze which one is the best.
It's Battle of the Bands, JMeter style.
Beanshell V. JSR223 V. Java Request Sampler
In our previous post, JMeter Performance and Tuning Tips (written by the fantastik Philipe Mouwad) we recommended using JSR 223 + Groovy for Scripting. It’s the best option as Groovy scripts can be compiled into native Java code (assuming some requirements are met) so Groovy script execution performance can be almost as fast as Java code.
Groovy脚本是一个进行测试很好的选择,因为它可以被编译成原生的Java代码,它执行效率可以和Java代码一样快。
So if you’re about to use scripts for something once, quick 'n dirty (e.g. reading configuration files at the beginning of the test) you’re welcome to use Beanshell/Javascript/whatever you’re comfortable with.
如果你只是想要使用脚本做一次什么事情,quick 'n dirty是啥意思,例如在测试开始时读取配置,你可以使用任何脚本。
But, if you’re about to do some extensive load testing through scripting (i.e. constructing massive HTTP requests from calculated data) you need to consider either Groovy or custom Java requests or a JMeter Sampler.
但是,如果您要通过脚本进行一些广泛的负载测试(即从计算数据构建大量HTTP请求),则需要考虑Groovy或自定义Java请求或JMeter Sampler。
For comparison purposes, we’re going to use the same simple code which generates a 1Mb string of r