JMeter custom Java sampler

时间:2017-04-24 17:27:03

标签: java jmeter performance-testing

I created a custom JMeter Java sampler. It does what I expect it to do, however, I want to properly populate the SampleResult.

In particular, I want to set the Received KB/sec manually. Is there a way to do this with the SampleResult class or some other endpoint?

In the SampleResult class there is a setBytes and a setSentBytes method but no received bytes method: https://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html

1 个答案:

答案 0 :(得分:0)

为什么不喜欢setBytes()方法?根据{{​​3}}:

  

public void setBytes(long length)

     

如果采样器确实想要传回实际内容,我们仍然想要计算吞吐量。 字节是响应数据的字节。

     

参数:

     

length - 此样本的响应数据的字节数

我认为您已熟悉JavaDoc指南

我个人并不喜欢开发"采样器"在99.9%的情况下,使用How to Write a plugin for JMeterJSR223 Test Elements可以实现相同的功能,这样您就不必花费额外的时间和精力来开发,支持和排除插件的问题,因为您可以跳过编译,打包,将新类添加到JMeter Classpath,重新启动JMeter等阶段,因此JSR223方法更快更方便,因为您可以直接在JMeter GUI中开发代码。