Jmeter定时器:Precise Throughput Timer使用

时间:2023-03-09 15:58:28
Jmeter定时器:Precise Throughput Timer使用

百度上这方面资料很少,google上有一些,我试着总结一下。

Precise Throughput Timer 是Jmeter4.0添加的新功能,直接摘录一段英文:

The Precise Throughput Timer is a timer that enables users to determine the throughput (samplers per second/minute/hour/etc.) they want to run in their tests. Compared to the Constant Throughput Timer, the user is more flexible when deciding how to spread out the samples over time. In addition, execution is scheduled in a random way, enabling a constant load to build up. Finally, this timer uses the Poisson arrival schedule for its pauses, making it close to real-life scenarios.

(不是翻译,就是说 Precise Throughput Timer 能让使用者控制吞吐量更灵活(每小时每分钟每秒等),并且如果定制了如一秒执行100次,那么这100次该如何分布(产生定制的恒定吞吐量的泊松分布(Poisson Distribution,二项式的随机概率分布)),是更棒的算法来实现随机分布,更接近实际情况。)

下面是一个例子:

Add a Precise Throughput Timer (Thread Group->Add->Timers->) .We have to achieve 100 requests by 5 users in 300 second. Setup the timers as per below setting:

a. Target throughout = 100

b.Throughput period (Seconds) = 300 (Total time to achieve the desired throughput).

c.Number of threads in the batch (threads)= 1

d.Use approximate throughput when sequence length exceeds (samples) = 100 (total no of requests)

e. Allowed throughput surplus (Percents) = 10

(不是翻译,这个例子就是说,300秒内,会执行100次请求,那么每秒是 100/300  就是0.3333的 throughput。)

(注意Throughput period (Seconds)  不能小于5,要不然会报错(Jmeter4.0版本))

Jmeter定时器:Precise Throughput Timer使用
这里有些配置没说,因为我也无法解释的很准确,google上资料也很少。(这个timer太少人用了)
我只能说是猜测:
Batched  departures 这部分是批处理的线程数,我倾向于理解是计算请求随机分布的线程数,就是说随机数的计算力。
Accuracy of generated delays  我理解是计算随机分布的参数,如果超过了队列,这个例子中是100个请求之后,会盈余10%。 我理解这个10%是随机数分布的一个参数,总体上还是  300/100 ,但是分布是由这个参数调整的。
所以,这个timer需要测试人对数学算法有了解了,这样才能调出来更接近实际情况的throughput。
如果比如说是24小时,执行一亿次,这一亿次来个随机分布,有高峰有低谷,那这个定时器确实就不简单了。
当然性能测试工作很难这么理想化,性能测试到后期肯定是全公司通力合作的一件事,上面1天一亿次的分布,是性能测试的探索方向,关键还是在于评价标准,要不然谁知道这么分布就对,那么分布就错呢。