标签:
一般情况下,我们都是通过Run-Time Settings来设置Think Time(思考时间),可以设置回放脚本时忽略思考时间,或者是设置回放随机的一段思考时间。
By default, when you run a Vuser script, the Vuser uses the think time values that were recorded into the script during the recording session. VuGen allows you to use the recorded think time, ignore it, or use a value related to the recorded time:
除此之外,我们还可以在VU脚本中编写随机函数设置随机思考时间:
Action()
{
// … your code
lr_think_time(fRandInteger(3, 12));
// … more of your code
return 0;
}
/*---- BEGIN Function fRandInteger --------------------------------------------------------*/
/* Send 2 arguments - minimum and maximum.
Output to caller is a random integer anywhere in the specified range, inclusive.*/
int fRandInteger(minInt, maxInt)
{
int rndInt, offset;
if (maxInt == 0)
return maxInt; // Caller must handle a 0 in order to prevent error.
offset = minInt;
rndInt = ((minInt) + rand() % (maxInt - offset + 1));
/* Examples:
1. lr_think_time(fRandInteger(3, 12));
2. rndVal = fRandInteger(1, 9);
3. rndVal = fRandInteger(1, CALLED_UFC_FIGHTER_A_WUSS_IN_PERSON); */
return rndInt;
}
/*---- END Function fRandInteger ------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------------*/
fRandInteger函数用于取某个区间中的一个随机整数。
参考:
http://www.sqablogs.com/JakeBrake
标签:
原文地址:http://www.cnblogs.com/hushaojun/p/5651631.html