Jmeter random variable in several threads
我有一个Jmeter线程组,它始终多次使用变量
换句话说,它以固定序列
我想同时运行多个线程,这带来了以下问题。
当我在线程组内将
如果将其全局设置,则会发生相同的情况。
完成后,我将同时运行数千个线程,因此无法执行手动解决方案或读/写磁盘。
外面有人有经验吗?
我浏览文档和Google已经有一段时间了,但是似乎找不到解决方案。
简而言之:我需要对一个变量进行随机化,在整个线程组中使用该变量,然后在多个并行线程中运行该线程组。该变量在每个不同的线程中应具有不同的随机值。
假设您可以简单地使用随机变量配置元素来代替:
1 2 3 4 5 | Variable Name: uuid Output Format: 12345678-1234-4444-a123-000000000000 Minimum Value: 111111111111 Maximum Value: 999999999999 Per Thread (User): True |
产生价值
-
可以作为
${uuid} 访问; - 每个线程唯一;
- 在不同采样器之间保留的调用每个线程的流程(在每个引用期间不会重新生成);
- 在线程组的每次迭代期间生成。
1 2 3 4 5 6 7 | Test Plan Thread Group Random Variable ... Sampler 1 Sampler 2 ... |
例如
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | iteration: 1 thread: 1 sampler 1: VALUE_1-1 sampler 2: VALUE_1-1 ... thread: 2 sampler 1: VALUE_2-1 sampler 2: VALUE_2-1 ... ... iteration: 2 thread: 1 sampler 1: VALUE_1-2 sampler 2: VALUE_1-2 ... thread: 2 sampler 1: VALUE_2-2 sampler 2: VALUE_2-2 ... ... |
为上面给出的模式实现的示例脚本:rnd-var.jmx
根据随机变量的
Default is the current time in milliseconds. If you use the same seed
value with Per Thread set to true, you will get the same value for
earch Thread as per Random class.If two instances of Random are created with the same seed, and the
same sequence of method calls is made for each, they will generate and
return identical sequences of numbers.
请牢记在实现具有高并发性的方案(如下面的注释中所述)。
为了克服这个问题,您可以使用随机种子,例如
刚放
1 | 12345678-1234-4444-a123-${__Random(111111111111,999999999999)} |
内联您需要的地方。
如果将其放在UDV组件中,则即使在启动线程之前也仅分配一次值。
根据jmeter文档,该行为还可以。请仔细阅读。