Jmeter Current Thread Number?

后端 未结 4 1250
耶瑟儿~
耶瑟儿~ 2021-02-06 23:24

I am using a Thread Group with Number Of Threads = 5 with an HTTP request.

In the request I want to include a parameter with the value of the thread number, e.g.,

<
4条回答
  •  无人及你
    2021-02-07 00:22

    While the above-mentioned ${__threadNum} will work in many places within jMeter, you'll need to use something else where it is not allowed, e.g., script elements within Pre/Post-Processors.

    This answer explains how to get thread number or count within such a script in jMeter.

    To get the number of the current thread (out of 5 in your case) use ctx.getThreadNum() which will get the number of the thread.

    To get the total number of threads being used by jMeter you can use ctx.getThreadGroup().getNumThreads() or ctx.getThreadGroup().getNumberOfThreads() for total active threads.

    https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html#getThreadNum() https://jmeter.apache.org/api/org/apache/jmeter/threads/AbstractThreadGroup.html

提交回复
热议问题