【问题标题】:Need resutls upto two decimal i.e seconds and miliseconds in jmeter在 jmeter 中需要最多两位小数 i.n 秒和毫秒的结果
【发布时间】:2021-06-22 09:28:24
【问题描述】:

我想在电子邮件正文中添加我的摘要报告结果。所以我根据我的请求添加了 bean shell 后处理器,并在其中添加了以下函数。

*<BeanShellPostProcessor guiclass="TestBeanGUI" testclass="BeanShellPostProcessor" testname="BeanShell PostProcessor" enabled="true">
            <boolProp name="resetInterpreter">false</boolProp>
            <stringProp name="parameters"></stringProp>
            <stringProp name="filename"></stringProp>
            <stringProp name="script">float duration = prev.getTime()/1000;
                 
props.put(&quot;getDTS_response&quot;, String.valueOf(duration));</stringProp>
          </BeanShellPostProcessor>*

邮件正文中使用的函数:

*&quot;Request 1 Reponse    ${__property(getDTS_response,0)} Seconds&quot;*

现在当我收到邮件正文中的结果时,显示如下。

针对请求 #1 的摘要报告结果:8563

邮件正文中请求 1 的结果:8.0 秒

针对请求 #2 的摘要报告结果:354

邮件正文中请求 1 的结果:0.0 秒

我希望我的结果如下:

邮件正文中请求 1 的结果:8.563 秒

邮件正文中请求 2 的结果:0.354 秒

请指导解决问题。

感谢和问候

【问题讨论】:

    标签: function jmeter performance-testing beanshell post-processor


    【解决方案1】:

    Since JMeter 3.1 you should be using JSR223 Test Elements and Groovy language 用于编写脚本,所以我将提供一个 Groovy 解决方案:

    (prev.getTime() / 1000).round(3)
    

    演示:

    更多信息:

    【讨论】:

      猜你喜欢
      • 2017-01-20
      • 1970-01-01
      • 2012-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-16
      • 1970-01-01
      相关资源
      最近更新 更多