在LoadRunner脚本中实现随机ThinkTime
一般情况下,我们都是通过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 脚本中做关联 (Correlation)
如何在 LoadRunner 脚本中做关联 (Correlation) 当录制脚本时,VuGen会拦截client端(浏览器)与server端(网站服务器)之间的对话,并且通通记录下来,产生脚本.在V ...
- loadrunner脚本中参数化和返回值输出log到外部文件
loadrunner脚本中参数化和返回值输出log到外部文件 很多时候,我们在做性能测试之前,需要造数据,但是使用的这些参数化数据和生成的返回数据在后面的测试都会用的,所以我们需要在造数据过程中,将参 ...
- loadrunner脚本中写入脚本输出log到外部文件,分析参数取值方式
loadrunner脚本中写入脚本输出log到外部文件,分析参数取值方式 分类: 心得 loadrunner 我的测试 2012-04-01 12:52 2340人阅读 评论(0) 收藏 举报 脚本l ...
- Loadrunner脚本回放 场景运行过程中常见错误分析
问题一:Loadrunner超时错误问题描述 Loadrunner超时错误:在录制Web协议脚本回放时超时情况经常出现,产生错误的原因也有很多,解决的方法也不同. 问题现象Error -27728: ...
- Loadrunner脚本编程(4)-数据类型操作和字符串操作
http://www.360doc.com/content/10/0806/13/1698198_44078277.shtml 一,数据类型转换 没有使用过C编程的LoadRunner脚本编写者会发现 ...
- LoadRunner脚本编写(6)— 数据类型转换和字符串操作
LoadRunner脚本编写(6)— 数据类型转换和字符串操作 一,数据类型转换 没有使用过C编程的LoadRunner脚本编写者会发现在数据类型转化方面比较困难.下面介绍这方面的知识. 1. 相似函 ...
- loadrunner 脚本和replaylog中的中文乱码问题(转载)
解决这个问题必须认识到一个事实就是,loadrunner和测试服务器交换数据使用的是utf8格式,但是展现在replaylog中是使用gb2312格式,而且在脚本中如何使用web_reg_find的时 ...
- 关注LoadRunner脚本回放日志中的Warning信息-转载
关注LoadRunner脚本回放日志中的Warning信息 最近在与大家的讨论中发现了LoadRunner的很多问题,出于解决问题的出发点,我也就相关自己不理解的问题在Google中搜索了一番,并 ...
- LoadRunner如何在注册业务脚本中设置参数化唯一性
LR在录制一个网站注册业务的脚本时,突然间遇到一个问题:注册时,由于注册用户需要验证唯一性,所以在LR回放脚本时,用Run-time Viewer工具回放可以发现(先在脚本中设置几个断点),真实运行的 ...
随机推荐
- python-函数(命名空间、作用域、闭包)
一.命名空间 全局命名空间 局部命名空间 内置命名空间 *内置命名空间中存放了python解释器为我们提供的名字:input,print,str,list,tuple...它们都是我们熟悉的,拿过来就 ...
- 举例说明如何使用【聚合数据】的API接口
0 注册[聚合数据]的账号 登陆www.juhe.cn,如图,如果没有账号,注册一个(手机号或者邮箱注册),如果有直接登陆即可. 1 搜索所需的API接口 找到聚合数据主页,在搜索框输入你想搜索的AP ...
- 一个杀不死的小强,kill进程无效的原因 记录故障排查过程中kill进程无效的分析过程
今天在处理一个机器异常负载(1000+)的问题,碰到了一个从未碰到过的情况,遇到了一个异常顽固的分子.我使用了所能想到的所有杀进程的方法,却始终无法干掉这个顽固分子,最后终于在谷歌大神的指引下,干掉了 ...
- Python 解释器中方向键无法使用的解决方法
如下: SyntaxError: invalid syntax >>> ^[[A File "<stdin>", line 1 ^ SyntaxErr ...
- [转载]数据层的多租户浅谈(SAAS多租户数据库设计)
原文:http://www.ibm.com/developerworks/cn/java/j-lo-dataMultitenant/index.html 在上一篇“浅析多租户在 Java 平台和某些 ...
- 使用moneykey对APP进行健壮性测试
注意:moneykey对app按钮伪随机点击,只能测试app稳定性和健壮性,无法进行常规测试 1.安装 A.jdk(不详细介绍) B.安装配置android配置环境:Android Studio 此环 ...
- FZU 2150 Fire Game 【两点BFS】
Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns) ...
- ZCMU Problem E: Subarray GCD(n个数的最大公约数)
Problem E: Subarray GCD Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 44 Solved: 27[Submit][Status ...
- KMP+差分 文章过滤器 (filter)
Description 给定一些短串,要求你在一个长串中,将这些短串部分变为\(*\) Input 第一行包括一个整数\(n\),表示短串的数量. 接下来的\(n\)行,为\(n\)个短串. 最后一行 ...
- Lightoj-1356 Prime Independence(质因子分解)(Hopcroft-Karp优化的最大匹配)
题意: 找出一个集合中的最大独立集,任意两数字之间不能是素数倍数的关系. 思路: 最大独立集,必然是二分图. 最大数字50w,考虑对每个数质因子分解,然后枚举所有除去一个质因子后的数是否存在,存在则建 ...