[JM_16]JMeter逻辑控制器-04:Transaction Controller、Throughput Controller
Transaction Controller、Throughput Controller属于第二类Logic Controller,用于对Test Plan中的脚本进行分组,便于JMeter统计执行结果,以及控制脚本的运行,该类控制器与节点逻辑执行顺序无关。
一、Transaction Controller(事务控制器)
事务控制器会生成一个额外的采样器来测量其下的测试元素的总体时间,该时间包含事务控制器范围内的所有处理时间,而不仅仅是采样器的处理时间
Attribute | Description | Required |
---|---|---|
Name | 事务控制器的名称 | Yes |
Generate parent sample | ①选中:事务采样器作为其下的采样器的父采样器 ②不选:作为额外的采样器添加在子采样器的后面 |
Yes |
PS:
-
对于JMeter2.3以上版本,有2种操作模式
1)事务采样器是作为其下采样器的父采样器
2)事务采样器是添加到其下子采样器的后面 -
事务采样器只有在其子采样器都成功的情况下才显示成功
-
生成的事务采样器的测量时间包括其下采样器以及其他的一切时间。由于时间频率的问题,这个时间可能略大于单个采样器的时间之和。时钟开始时间介于控制器记录开始时间与第一个采样器开始之间,时钟结束时间亦然
-
在父模式下,事务控制器下的各个采样器只有在the Tree View Listener里才能看到。同时,子采样器的数据也不会在csv文件中显示,但是在XML文件中可以看到




二、Throughput Controller(吞吐量控制器)
适用场景:JMeter测试多个接口(对应不同的业务),分别通过Throughput Controller进行控制分配不同比例的并发用户数
案例:
业务项 | Percent Executions |
---|---|
访问Bing | 10% |
访问Sogou | 20% |
访问Baidu | 50% |
访问Yahoo | 20% |



Throughput Controller参数设置:
Throughput | Per User | |
---|---|---|
Percent Executions | 执行百分比 | 空(默认) |
Percent Executions | 执行百分比 | √ |
Total Executions | 总执行量 | 空(默认) |
Total Executions | 总执行量 | √ |

Pre-Condition:

1.Percent Executions
1)不勾选Per User(默认)
运行次数=线程数×循环次数×吞吐量(%)=10×2×10%=2

2)勾选Per User
暂未有运行记录(待进一步验证,网上有教程说是此时勾选和不勾选产生的效果是一样的)

2.Total Executions
1)不勾选Per User(默认)
运行次数=吞吐量=10

2)勾选Per User
运行次数=吞吐量×循环次数=10×2=20(似乎与官方用户手册说明的规则不一致,暂不确定)

以上,关于Throughput Controller的参数配置项中Per User选择,建议目前还是默认的不勾选此项进行配置;因勾选此项后相关规则和实际执行过程仍然存在不一致和不确定性,甚至出现无数据记录的情况,待后续验证再作完善