一般情況下,我們都是通過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函數用於取某個區間中的一個隨機整數。