在使用Groovy时,如何在Jmeter中的JSR233采样器中添加交易?

发布于 2025-02-01 02:37:20 字数 244 浏览 2 评论 0 原文

我正在与JSR233合作进行SFTP PE测试。以下是一个粗糙的流程图。 现在,我想仅捕获文件删除的事务时间。我们如何在Jmeter中实现这一目标?

I am working with JSR233 for sFTP PE testing. following is a rough flow diagram.
Now I want to capture transaction time for file drop only. how can we achieve this in jmeter ?

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白芷 2025-02-08 02:37:20

有两个选项:

  1. 添加 subresult 对于每个步骤,即

      def stapenconnection = new org.apache.jmeter.samplers.sampleresult()
    stuperconnection.samplestart()
    //代码建立连接
    stuperconnection.setsamplelabel('建立连接')
    建立Connection.setsuccessful(true)
    shopenconnection.sampleend()
    采样
    
    def dropfile = new org.apache.jmeter.samplers.sampleresult()
    dropfile.samplestart()
    //代码删除文件
    dropfile.setsamplelabel('drop file')
    dropfile.setsuccessful(true)
    dropfile.sampleend()
    Sampleresult.AddSubresult(Dropfile)
     

    因此,您将为每个动作获得单独的子归因:

    “在此处输入图像描述”

  2. 您可以覆盖JSR223采样器经过的时间,并从 jsr223 Postprocessor 带有简单的代码

      prev.elapsedtime = 1000
    //用IE Jmeter变量替换1000
     

有关jmeter中刻板脚本的更多信息:

There are 2 options:

  1. Add a SubResult for each step i.e.

    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)
    

    so you will get separate sub-result for each action:

    enter image description here

  2. You can overwrite the JSR223 Sampler elapsed time with an arbitrary value from the JSR223 PostProcessor with the simple code like:

    prev.elapsedTime = 1000
    //replace 1000 with i.e. JMeter Variable holding the value of "drop file" event
    

More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文