首先是从jmeter的官方使用手册中找到的,constant throughput timer如下:
18.6.4 Constant Throughput Timer |
This timer introduces variable pauses, calculated to keep the total throughput (in terms of samples per minute) as close as possible to a give figure. Of course the throughput will be lower if the server is not capable of handling it, or if other timers or time-consuming test elements prevent it. N.B. although the Timer is called the Constant Throughput timer, the throughput value does not need to be constant. It can be defined in terms of a variable or function call, and the value can be changed during a test. The value can be changed in various ways:
- using a counter variable
- using a JavaScript or BeanShell function to provide a changing value
- using the remote BeanShell server to change a JMeter property
See Best Practices for further details. Note that the throughput value should not be changed too often during a test - it will take a while for the new value to take effect. Control Panel
Parameters
Attribute | Description | Required |
---|
Name | Descriptive name for this timer that is shown in the tree. | No | Target Throughput | Throughput we want the timer to try to generate. | Yes | Calculate Throughput based on |
- this thread only - each thread will try to maintain the target throughput. The overall throughput will be proportional to the number of active threads.
- all active threads in current thread group - the target throughput is divided amongst all the active threads in the group. Each thread will delay as needed, based on when it last ran.
- all active threads - the target throughput is divided amongst all the active threads in all Thread Groups. Each thread will delay as needed, based on when it last ran. In this case, each other Thread Group will need a Constant Throughput timer with the same settings.
- all active threads in current thread group (shared) - as above, but each thread is delayed based on when any thread in the group last ran.
- all active threads (shared) - as above; each thread is delayed based on when any thread last ran.
| Yes |
|
|
固定吞吐量定时器(Constant Throughput Timer)可以让JMeter以指定数字的吞吐量(即指定TPS,只是这里要求指定每分钟的执行数,而不是每秒)执行。吞吐量计算的范围可以为指定为当前线程、当前线程组、所有线程组,并且计算吞吐量的依据可以是最近一次线程的执行时延。
如果想自己定义throughput的变化也是可以的,需要使用BeanShell定时器(BeanShell Timer)
这个定时器,平时用不上。但实际上,它是最强大的,因为可以自己编程实现想要干的任何事。有复杂需求时,就要靠它了。例如,希望在每个线程执行完等待一下,或者希望在某个变量达到指定值的时候等待一下。