从 Jmeter jtl 日志文件计算吞吐量

发布于 2024-10-19 11:36:44 字数 1056 浏览 2 评论 0原文

我试图找出一个公式来计算吞吐量(请求数/时间单位),该公式基于 jtl 日志中的一些属性,基于以下参数:

  • 时间戳 (ts)
  • 时间 (t)
  • 总请求数

看一下时间戳我不完全确定它是指发送请求的时间还是收到响应的时间(这里是我的主要困惑点)。看一下这些值,第一个选项似乎更有可能。因此,假设这一点,我得出以下结论:

Throughput = (NumRequests / (max(ts + t) - min(ts)) ) * 1000

谁能告诉我我的观点是否正确?

更新(并感谢 @BlackGaff 的回复)

要点是我需要在非 GUI 环境中执行测试并收集某些自动化流程的结果,因此我无法真正使用聚合报告(除非有办法从命令行运行它)。使用 max & min 尝试从一组请求中查找 ts 值(在同一测试中)。另外,如果我将采样器配置为具有不同于 0 的上升周期(因此负载是分布式的),则我得到的 ts 数字是不同的。是的,正如您之前提到的,我实际上正在寻找第一个样本的开始时间和最后一个样本的结束时间之间的差异。除此之外,我在 jmeter.properties 中找到了一个参数:

# Put the start time stamp in logs instead of the end
#sampleresult.timestamp.start=true

所以根据这个参数,我似乎还应该更改计算以获取开始和结束时间。

注意:我很好奇如何根据 jtl 文件计算此值,但如果有人需要从命令行获取这些数字,请尝试添加“生成摘要报告”侦听器,在 jmeter 日志中,您将得到类似于以下内容的行执行结束时出现以下内容:

2011/03/10 22:31:42 INFO  - jmeter.reporters.Summariser: Generate Summary Results =   200 in   9.8s =   20.5/s Avg:    95 Min:    75 Max:   315 Err:     0 (0.00%)

I was trying to come out with a formula to calculate the throughput (number requests/time unit) based on some properties from the jtl log based on the following parameters:

  • Timestamp (ts)
  • Time (t)
  • Number of total requests

Taking a look at the timestamps I was not completely sure if it refers to the time when the request was sent or when it received the response (my main point of confusion here). Taking a look at the values the first options seems more likely. So assuming this, I've come out with the following:

Throughput = (NumRequests / (max(ts + t) - min(ts)) ) * 1000

Can anyone tell me if I'm right with this?

Update (and thanks for the response @BlackGaff )

The point is that I need to execute my tests and gather the results in a non-gui environment for some automated processes, so I can't really use the Aggregate Report (unless there is a way to run it from the command line). The use of max & min is an attempt to find the ts values from a set of requests (within the same test). Also, if I configure the samplers to have a ramp up period different than 0 (so the load is distributed), the numbers I get for ts are different. And yes, as you already mentioned before, I'm effectively looking for the difference between startTime of the first sample and endTime of the last sample. Apart from that I found a parameter in jmeter.properties:

# Put the start time stamp in logs instead of the end
#sampleresult.timestamp.start=true

So depending on this parameter it seems I should also change the calculation to get the start and end times.

NOTE: I'm curious about how to calculate this based on the jtl file but if anyone needs to get these numbers from the command line try adding the "Generate Summary Report" listener, and in the jmeter logs you will get a line similar to the following at the end of the execution:

2011/03/10 22:31:42 INFO  - jmeter.reporters.Summariser: Generate Summary Results =   200 in   9.8s =   20.5/s Avg:    95 Min:    75 Max:   315 Err:     0 (0.00%)

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

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

发布评论

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

评论(3

帅气尐潴 2024-10-26 11:36:44

在 Jmeter 的聚合报告中打开 JTL 日志是否会更容易,该报告将为您计算吞吐量,然后将其保存回来?

但是,就问题而言。

目前,您的公式具有时间/请求单位。考虑到您想要请求/时间,公式应为:

Throughput = (NumRequests / (max(ts + t) - min(ts) ) ) * 1000

我不完全确定为什么要使用最大值和最小值,因为您只提供一个值,而这些函数从一组返回最大值/最小值。鉴于 TS 是相同的值,使用 EXCEL,您最终会得到:

Throughput = (NumRequests/t*1000)

我相信您真正想要的是第一个样本的 startTime 和最后一个样本的 endTime 之间的差异)

根据术语表:

吞吐量计算如下
请求/时间单位。时间是
从第一个开始计算
采样到最后一个采样的末尾。
这包括之间的任何间隔
样本,正如它应该的那样
代表服务器上的负载。这
公式为:吞吐量=(数量
请求)/(总时间)。

给出最终公式:

endTime = lastSampleStartTime + lastSampleLoadTime
startTime = firstSampleStartTime
converstion = unit time conversion value

Throughput = Numrequests / ((endTime - startTime)*conversion)

Might it be easier to open the JTL log in Jmeter's Aggregate report, which will calculate the Throughput for you, and then save it back out?

But, on point with the question.

Currently, your formula has units of time / requests. Given you want requests/time, you the formula should read:

Throughput = (NumRequests / (max(ts + t) - min(ts) ) ) * 1000

I'm not entirely sure why you're using max and min, since you're only providing one value and those functions return the max/min from a set. Given that TS is the same value, using EXCEL, you end up with:

Throughput = (NumRequests/t*1000)

I believe what you really want is the difference between startTime of the first sample and endTime of the last sample)

Per the glossary:

Throughput is calculated as
requests/unit of time. The time is
calculated from the start of the first
sample to the end of the last sample.
This includes any intervals between
samples, as it is supposed to
represent the load on the server. The
formula is: Throughput = (number of
requests) / (total time).

Giving a final formula of:

endTime = lastSampleStartTime + lastSampleLoadTime
startTime = firstSampleStartTime
converstion = unit time conversion value

Throughput = Numrequests / ((endTime - startTime)*conversion)
淤浪 2024-10-26 11:36:44

重点是我需要执行测试并将结果收集在
一些自动化流程的非 GUI 环境,所以我真的不能
使用聚合报告(除非有办法从
命令行)。

有。您可以使用 JMeter 插件项目中的 CMD 工具生成 CSV 格式的聚合报告。

http://jmeter-plugins.org/wiki/JMeterPluginsCMD/

The point is that I need to execute my tests and gather the results in
a non-gui environment for some automated processes, so I can't really
use the Aggregate Report (unless there is a way to run it from the
command line).

There is. You can use CMD tool from JMeter Plugins project to generate Aggregate report in CSVs.

http://jmeter-plugins.org/wiki/JMeterPluginsCMD/

笑忘罢 2024-10-26 11:36:44

假设您要计算 20 个线程的吞吐量。以下是要遵循的步骤:

  1. 清理 jtl 文件,仅保留 20 个线程的剩余条目。使用 20 个线程调用保存此文件。
  2. 使用以下命令从时间戳获取小时分钟秒

    awk -F"[, .]" '{print $2}' 摘要.jtl > tps1
    
  3. 运行以下命令以获取吞吐量/秒

    排序 tps1 | uniq-c> tps2
    

Assuming the you want to calculate the throughput at 20 threads. Following are the steps to follow:

  1. Clean the jtl file with remaining entries just for 20 threads. Save this file with 20 threads calls.
  2. Get the hour min sec from the time stamp using following command

    awk -F"[, .]" '{print $2}' summary.jtl > tps1
    
  3. Run following command to get throughput / sec

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