使用 Groovy 时如何在 jmeter 的 jsr233 采样器中添加事务?
How to add transaction in jsr233 sampler in jmeter while using Groovy?
我正在使用 JSR233 进行 sFTP PE 测试。以下是一个粗略的流程图。
现在我只想捕获文件删除的事务时间。我们如何在 jmeter 中实现这一点?
有2个选项:
为每个步骤添加一个 SubResult 即
def establishConnection = new org.apache.jmeter.samplers.SampleResult()
establishConnection.sampleStart()
//code to establish connection
establishConnection.setSampleLabel('Establish Connection')
establishConnection.setSuccessful(true)
establishConnection.sampleEnd()
SampleResult.addSubResult(establishConnection)
def dropFile = new org.apache.jmeter.samplers.SampleResult()
dropFile.sampleStart()
//code to drop the file
dropFile.setSampleLabel('Drop File')
dropFile.setSuccessful(true)
dropFile.sampleEnd()
SampleResult.addSubResult(dropFile)
因此您将针对每个操作获得单独的 sub-result:
您可以使用 JSR223 PostProcessor 中的任意值覆盖 JSR223 采样器运行时间,使用简单的代码,例如:
prev.elapsedTime = 1000
//replace 1000 with i.e. JMeter Variable holding the value of "drop file" event
有关 JMeter 中 Groovy 脚本的更多信息:Apache Groovy - Why and How You Should Use It
我正在使用 JSR233 进行 sFTP PE 测试。以下是一个粗略的流程图。 现在我只想捕获文件删除的事务时间。我们如何在 jmeter 中实现这一点?
有2个选项:
为每个步骤添加一个 SubResult 即
def establishConnection = new org.apache.jmeter.samplers.SampleResult() establishConnection.sampleStart() //code to establish connection establishConnection.setSampleLabel('Establish Connection') establishConnection.setSuccessful(true) establishConnection.sampleEnd() SampleResult.addSubResult(establishConnection) def dropFile = new org.apache.jmeter.samplers.SampleResult() dropFile.sampleStart() //code to drop the file dropFile.setSampleLabel('Drop File') dropFile.setSuccessful(true) dropFile.sampleEnd() SampleResult.addSubResult(dropFile)
因此您将针对每个操作获得单独的 sub-result:
您可以使用 JSR223 PostProcessor 中的任意值覆盖 JSR223 采样器运行时间,使用简单的代码,例如:
prev.elapsedTime = 1000 //replace 1000 with i.e. JMeter Variable holding the value of "drop file" event
有关 JMeter 中 Groovy 脚本的更多信息:Apache Groovy - Why and How You Should Use It