在LoadRunner脚本中实现随机ThinkTime
来源:互联网 发布:守望先锋配置测试软件 编辑:程序博客网 时间:2024/04/30 18:19
一般情况下,我们都是通过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:
- Ignore think time. Ignore the recorded think time—replay the script ignoring all lr_think_time functions.
- Replay the think time. The second set of think times options let you use the recorded think time:
- As recorded. During replay, use the argument that appears in the lr_think_time function. For example, lr_think_time(10) waits ten seconds.
- Multiply recorded think time by. During replay, use a multiple of the recorded think time. This can increase or decrease the think time applied during playback. For example, if a think time of four seconds was recorded, you can instruct your Vuser to multiply that value by two, for a total of eight seconds. To reduce the think time to two seconds, multiply the recorded time by 0.5.
- Use random percentage of the recorded think time. Use a random percentage of the recorded think time. You set a range for the think time value by specifying a range for the think time. For example, if the think time argument is 4, and you specify a minimum of 50% and a maximum of 150%, the lowest think time can be two (50%) and the highest value six (150%).
- Limit think time to. Limit the think time's maximum value.
除此之外,我们还可以在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
- 在LoadRunner脚本中实现随机ThinkTime
- loadrunner中 thinktime 如何运用随机时间,并要把时间定在毫秒级
- loadrunner-thinktime
- Loadrunner中 实现在WebTours中随机订票
- LoadRunner之--ThinkTime
- [转]Loadrunner中考虑时间(ThinkTime)介绍
- 如何在 LoadRunner 脚本中做关联
- 如何在LoadRunner脚本中做关联
- 在loadrunner中调用QTP脚本
- Loadrunner 实现随机日期
- 如何在 LoadRunner 脚本中做关联 (Correlation)
- 如何在 LoadRunner 脚本中做关联 (Correlation)
- 在LoadRunner脚本中处理HTTP重定向
- 如何在LoadRunner场景设计中设置串行脚本执行
- 如何在 LoadRunner 脚本中做关联 (Correlation)
- 如何在 LoadRunner 脚本中做关联 (Correlation)
- 性能loadrunner--使用loadrunner录制脚本时集合点只能在Action中插入
- Loadrunner中socket脚本分析
- exercise permutation
- 走出软件作坊》读后感想
- LabVIEW
- java 连接字符串
- 如何检测系统是否已经运行了相同的程序
- 在LoadRunner脚本中实现随机ThinkTime
- MySQL命令行中文乱码解决办法
- GC日志监听器
- JAVA读取PDF文件
- flex 优化技巧 收集[提升性能]
- 今天配置了一下Emacs字体
- Java读取PDF,Doc的方法
- 玩了一下C52
- 各种jQuery插件