如何设置条件以仅针对特定数量的用户执行某些步骤 [英] How can I set condition to execute some steps just for particular amount of users

查看:73
本文介绍了如何设置条件以仅针对特定数量的用户执行某些步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在jmeter中设置条件,使80%的用户将执行该条件,而20%的用户将不执行该条件.请帮我. 我有一个http采样器,我希望它仅对测试中的80%用户执行,因此当用户数(线程)改变时,对该采样器执行的请求的百分比将保持不变.

How can I set condition in jmeter for a step that 80% of users will execute it and the 20% of users will not. Please help me for this. I have a http sampler and I want it to execute just for 80% of users in the test, so when number of users (threads) will change the percentage of executed requests for that sampler will stay the same.

推荐答案

如果有些采样器只想在某些线程中使用,而不是全部,那么最简单的方法是将它们添加到If Controller并在Condition中添加像这样:

If you have some samplers that you want to work with just in some threads, not all, the easiest way is to add them to If Controller and in Condition add something like:

${__Random(1,100)} <= 80

在那种情况下,该控制器中的请求有80%的机会运行(仅当random小于或等于80时才触发).当然,它并不是完美的,因为有时它可以处理+ -5%的请求,但这是我所知道的最快,最简单的方法.有了这种随机性,它更像是现实生活中的经验.

In that case requests in that controller has 80% chance to run (fires only when random is lower or equal than 80). Of course it's not perfect, as sometimes it can go with +-5% of requests but it's fastest and easiest way I know. And with that sort of randomness it's more like real life experience.

这篇关于如何设置条件以仅针对特定数量的用户执行某些步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆