// Cast the iterator parameter to an int
var i;
i = atoi(lr_eval_string("{iterator}"));
// This will run 100 TPH
if ((i % 10) == 0)
{
lr_start_transaction("Login");
// Do login
...
lr_end_transaction("Login", LR_AUTO);
}
另一个例子,要运行200 TPH,您可以使用 iterator % 5 :
// This will run 200 TPH
if ((i % 5) == 0)
{
lr_start_transaction("Add Product");
// Do Add Product
...
lr_end_transaction("Add Product", LR_AUTO);
}
1 回答
如果所有这些事务都在不同的脚本中,没问题,因为您可以为每个脚本设置不同的调步和运行时设置 .
我假设您的问题是所有这些交易都在 same script 中 . 在这种情况下,唯一的解决方案是在脚本中创建一个参数,让我们调用此参数
iterator
,并将其类型设置为 iteration number . 这样,该参数在第一次迭代中的值为1,在第二次迭代中的值为2,等等 .现在,您可以在调用每个事务之前使用此参数 .
假设您的最高TPH为1,000 . 然后将脚本的运行时设置速度设置为1,000 TPH . 但是如果你想让一个特定的事务运行得少于那个,假设只有100个TPH,那么你需要每隔10次迭代运行它(1,000 / 100 = 10) .
为此,在脚本中,您可以使用
iterator % 10
:另一个例子,要运行200 TPH,您可以使用
iterator % 5
: