Jmeter - 图形变量

Jmeter - Graph variable

在我的 JMeter 测试期间,我从响应消息中提取一个浮点值,并使用正则表达式提取器将其保存到一个变量中,我还将该值保存在生成​​的测试结果 csv 文件中。现在我希望能够生成这个提取的浮点值的图表,但还没有找到这样做的方法,或者已经找到创建我自己的图表插件来绘制这个值的图表的示例。

在下一个版本的 JMeter 5.0 中,您可以通过添加 user.properties 来做到这一点:

sample_variables=VarName
jmeter.reportgenerator.graph.custom_mm_hit.classname=org.apache.jmeter.report.processor.graph.impl.CustomGraphConsumer
jmeter.reportgenerator.graph.custom_mm_hit.title=Graph Title
jmeter.reportgenerator.graph.custom_mm_hit.property.set_Y_Axis=Response Time (ms)
jmeter.reportgenerator.graph.custom_mm_hit.property.set_X_Axis=Over Time
jmeter.reportgenerator.graph.custom_mm_hit.property.set_granularity=${jmeter.reportgenerator.overall_granularity}
jmeter.reportgenerator.graph.custom_mm_hit.property.setSampleVariableName=VarName
jmeter.reportgenerator.graph.custom_mm_hit.property.setContentMessage=Message for graph point label

在上面的例子中:

  • VarName 是你的变量名
  • custom_mm_hit 将是您图表的唯一 ID,您应该更改它但始终以“custom_”为前缀“=31=]

要配置和生成图表,请参阅:

您将在自定义图表部分获得一个新的价值随时间变化的图表。

要下载稳定的 nightly build,snd 将非常接近 5.0,请参阅:

您可以使用 Sample Variables 属性 将浮点值保存到 .jtl 结果文件中

  1. 将下一行添加到 user.properties 文件:

    sample_variables=foo
    

    foo 替换为来自正则表达式提取器的实际 JMeter 变量引用名称

  2. 下次 运行 测试时,您会在 .jtl 结果文件中看到一个额外的列,其中包含浮点变量值。另一种选择是通过 -J command-line argument 设置此 属性,例如

    jmeter -Jsample_variables=foo -n -t test.jmx -l result.jtl
    

有关使用属性调整 JMeter 引擎的更多信息,请参阅 Configuring JMeter and Apache JMeter Properties Customization Guide 文章。

获得存储的值后,您可以使用 LibreOffice Calc or Microsoft Excel 或等效方法绘制图表。


如果你想想出一个插件来绘制自定义变量,你可以从 How to write a plugin for JMeter guide and then look into source of i.e. Latencies Over Time plugin which lives in GitHub

开始