如何在 JMeter 中每 N 个循环增加一个计数器?

发布于 2024-09-09 11:02:27 字数 592 浏览 2 评论 0原文

我想测试并发性,并可靠地复制 JMeter 引起我注意的问题。

我想要做的是设置一个唯一标识符(当前以毫秒为单位的时间并附加计数器)并在循环之间而不是线程之间增加计数器。我的想法是,我设置的线程数是在递增和使用另一个标识符之前相同标识符的数量。

如果我有 3 个循环计数为 2 的线程,我想要:

1. Unique ID: <current-time-in-millis>000000
2. Unique ID: <current-time-in-millis>000000
3. Unique ID: <current-time-in-millis>000000
4. Unique ID: <current-time-in-millis>000001
5. Unique ID: <current-time-in-millis>000001
6. Unique ID: <current-time-in-millis>000001

我尝试使用吞吐量控制器来增加计数器,以及其他一些看起来应该可以工作但没有运气的东西。这似乎是 JMeter 应该能够做到的事情。有什么方法可以获取循环计数的值吗?

I want to test concurrency, and reliably replicate an issue that JMeter brought to my attention.

What I want to do is set a unique identifier (currently the time in milliseconds with a counter appended) and increment the counter between loops but not between threads. The idea being that the number of threads I have set up is the number of identical identifiers before incrementing and using another.

If I had 3 threads with a loop count of 2 I want:

1. Unique ID: <current-time-in-millis>000000
2. Unique ID: <current-time-in-millis>000000
3. Unique ID: <current-time-in-millis>000000
4. Unique ID: <current-time-in-millis>000001
5. Unique ID: <current-time-in-millis>000001
6. Unique ID: <current-time-in-millis>000001

I've tried using Throughput Controllers to increment a counter, as well as several other things that seemed they should work but had no luck. This seems like something JMeter should be able to do. Is there any way to get the value of the loop count?

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

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

发布评论

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

评论(2

远山浅 2024-09-16 11:02:27

Counter 是解决方案吗?

或使用 __intSum

初始化变量(例如在“用户定义的变量”中):

Name:       | Value
------------+---------
LoopCounter | 0

使用增量无论您何时需要:

${__intSum(${LoopCounter},1,LoopCounter)}

使用:

${LoopCounter}

Is Counter the solution?

or use __intSum

init variable (eg in "User Defined Variables"):

Name:       | Value
------------+---------
LoopCounter | 0

use increment where ever you need:

${__intSum(${LoopCounter},1,LoopCounter)}

using:

${LoopCounter}
ら栖息 2024-09-16 11:02:27

您是否尝试过使用预处理器计数器元素上的“为每个用户独立跟踪计数器”选项?

我的理解是,这应该为每个线程组提供一个单独的计数器。

Have you tried playing with the "track counter independently for each user" option on the pre-processor Counter element?

My understanding is that this should give you a separate counter for each thread group.

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