LoadRunner 事物
添加事物

Action()
{
lr_start_transaction("openindex");
web_url("WebTours",
"URL=http://127.0.0.1:1080/WebTours/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t3.inf",
"Mode=HTTP",
LAST);
lr_end_transaction("openindex", LR_AUTO);
return ;
}
运行结果:
Action.c(): 通知: Transaction "openindex" started.
Action.c(): web_url("WebTours") 已成功, 个正文字节, 个标头字节 [MsgId: MMSG-]
Action.c(): 通知: Transaction "openindex" ended with "Pass" status (Duration: 0.4420 Wasted Time: 0.3987).
lr_end_transaction的4中状态
LR_PASS LR_FAIL 自定义事物成功和失败。也可以用 lr_set_transaction_status_by_name(LR_FAIL,"openindex"); 函数自定义事物状态
Action()
{
int status ;
lr_start_transaction("openindex");
//web_url 成功返回0 失败返回1
status =web_url("WebTours",
"URL=http://127.0.0.1:1080/WebTours1/", //不存在的网址
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t3.inf",
"Mode=HTTP",
LAST);
if (status==0) {
lr_end_transaction("openindex", LR_PASS);
}else{
lr_end_transaction("openindex", LR_FAIL);
}
return ;
}
运行结果:
网址不存在
Action.c(): 通知: Transaction "openindex" ended with "Fail" status (Duration: 0.4105 Wasted Time: 0.3801).
如果网址存在,请求成功:
Action.c(): 通知: Transaction "openindex" ended with "Pass" status (Duration: 0.3951 Wasted Time: 0.3687).
LR_AUTO
Action()
{
lr_start_transaction("openindex");
web_url("WebTours",
"URL=http://127.0.0.1:1080/WebTours/1", //不存在的网址
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t3.inf",
"Mode=HTTP",
LAST);
lr_end_transaction("openindex", LR_AUTO);
return ;
}
运行结果:
Action.c(): 通知: Transaction "openindex" ended with "Fail" status (Duration: 0.4072 Wasted Time: 0.3774).
Action()
{
lr_start_transaction("openindex");
web_url("WebTours",
"URL=http://127.0.0.1:1080/WebTours/", //网址正确
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t3.inf",
"Mode=HTTP",
LAST);
lr_set_transaction_status_by_name(LR_FAIL,"openindex"); //手动设置事务失败
lr_end_transaction("openindex", LR_AUTO);
return ;
}
结果:
Action.c(): 通知: Transaction "openindex" ended with "Fail" status (Duration: 0.4284 Wasted Time: 0.3811).
LR_STOP
事物返回时间的详细解释
Action.c(): 通知: Transaction "openindex" ended with "Fail" status (Duration: 0.4284 Wasted Time: 0.3811).
Duration(持续时间):事物开始一共的时间。包括Wasted Time、代码浪费时间。在Analysis获取的是 Duration-Wasted Time时间。
Wasted Time(浪费的时间):LR为了支撑,工具内部的时间。事物的统计。用lr_start_timer() lr_end_timer()函数获取。
Action()
{
lr_start_transaction("openindex");
web_url("WebTours",
"URL=http://127.0.0.1:1080/WebTours/", //网址正确
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t3.inf",
"Mode=HTTP",
LAST);
//lr_think_time(3);
lr_output_message("Duration:%lf;Wasted Time=%lf",lr_get_transaction_duration("openindex"),lr_get_transaction_wasted_time("openindex"));
lr_end_transaction("openindex", LR_AUTO);
return ;
}
运行结果:
Action.c(): Duration:0.389529;Wasted Time=0.361978
去掉lr_think_time注释
Action.c(13): Duration:3.384649;Wasted Time=0.352630 //Duration多了3秒
Action.c(14): 通知: Transaction "openindex" ended with "Pass" status (Duration: 3.3882 Think Time: 2.9994 Wasted Time: 0.3526).
程序消耗时间:
Action()
{
merc_timer_handle_t timer;
char save[];
double wasteTime;
int i;
lr_start_transaction("openindex");
web_url("WebTours",
"URL=http://127.0.0.1:1080/WebTours/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t3.inf",
"Mode=HTTP",
LAST);
timer=lr_start_timer();
for(i=0;i<1000;i++){
sprintf(save,"this is the way we wasteTime in a script %d",i);
}
wasteTime=lr_end_timer(timer);
//lr_wasted_time(wasteTime*1000); //把浪费的时间加到WastedTime.因为wasteTime是秒。lr_wasted_time接收的是毫秒。所以好*1000
lr_output_message("Duration:%lf;Wasted Time=%lf",lr_get_transaction_duration("openindex"),lr_get_transaction_wasted_time("openindex"));
lr_end_transaction("openindex", LR_AUTO);
return ;
}
运行结果:
Action.c(): 通知: Transaction "openindex" ended with "Pass" status (Duration: 3.0407 Wasted Time: 0.3701). 持续时间包括了程序时间。
去掉 lr_wasted_time注释。运行结果
Action.c(23): 通知: Transaction "openindex" ended with "Pass" status (Duration: 3.7046 Wasted Time: 3.6650).
可以看到for循环运行的时间,被加到了Wasted Time
需要注意的
1)事务中不要插入日志函数
2)不要插入集合点函数
3)尽量不要插入思考时间
LoadRunner 事物的更多相关文章
- LoadRunner去除事物中的程序的执行时间
大家在性能测试过程中,经常会用到程序处理或组织数据,以达到一定的测试目的,但是程序本身执行会消耗一些时间,这部分消耗的时间是包含在响应时间里面,此时,响应时间=正常响应时间+程序执行消耗时间.那么如何 ...
- LoadRunner中响应时间与事物时间详解
1. 响应时间 事务是指用户在客户端做一种或多种业务所需要的操作集,通过事务函数可以标记完成该业务所需要的操作内容:另一方面事务可以用来统计用户操作的响应时间,事务响应时间是通过记录用户请求的开始时间 ...
- LoadRunner通过验证参数判断事物的成功与失败
if(atoi(lr_eval_string("{Param_DiscountID}")) > 0){ //lr_message("多机多酒:%s",lr ...
- loadrunner总体使用篇
为什么要进行性能测试呢? 有些问题是只有在大并发或者压力测试下才会暴露出来的,在平常的公司内部测试中,感觉一切都是正常的,但是把服务放到生产线上,例如某个时刻突然有很多的用户要向我们的服务发送请求, ...
- 转 LoadRunner 技巧之 IP欺骗 (推荐)
IP欺骗也是也loadrunner自带的一个非常有用的功能. 需要使用ip欺骗的原因: 1.当某个IP的访问过于频繁,或者访问量过大是,服务器会拒绝访问请求,这时候通过IP欺骗可以增加访问频率和访问量 ...
- loadrunner的基本操作
一.遗留问题: 1.controller中,到设置的时间后,仍然在运行: 2.如何对多个用例的结果进行分析,找到系统可以承受的最佳的用户数量点: 3.vuser与实际的用户访问数量是一回事吗?比如vu ...
- LoadRunner ---思考时间设置
用户访问某个网站或软件,一般不会不停地做个各种操作,例如一次查询,用户需要时间查看查询的结果是否是自己想要的.例如一次订单提交,用户需要时间核对自己填写的信息是否正确等. 也就是说用户在做某些操作时, ...
- LoadRunner测试50人同时登陆下单
LoadRunner测试50人同时登陆下单 一.LoadRunner简介 LoadRunner,是一种预测系统行为和性能的负载测试工具.通过以模拟上千万用户实施并发负载及实时性能监测的方式来确认和查找 ...
- LoadRunner - 当DiscuzNT遇上了Loadrunner(下) (转发)
当DiscuzNT遇上了Loadrunner(下) 在之前的两篇文章中,基本上介绍了如何录制脚本和生成并发用户,同时还对测试报告中的几个图表做了简单的说明.今天这篇文章做为这个系列的最后一篇,将会介绍 ...
随机推荐
- grep 常用正则匹配
1.或操作 grep -E '123|abc' filename // 找出文件(filename)中包含123或者包含abc的行 egrep '123|abc' filename // 用egrep ...
- python的一些开源库
SQLAlchemy——数据持久层框架 简介 SQLAlchemy 主要由两部分组成,一个 SQL 工具包和一个关系对象映射(ORM),它能让开发者完全发挥出 SQL 的灵活性与强大的能量.他实现了一 ...
- matlab算法转为c语言注意事项
matlab算法转为c语言后,影响c语言效率的关键在于multiword的产生,基于此会有multiword加减法和乘除法,极大消耗资源,减少甚至消除multiword很重要,需注意的是:算法中尽量减 ...
- 解决Iframe session过期,登录界面无法全页刷新
在登录界面增加如下js代码: <script language=”JavaScript”> if (window != top) top.location.href = location. ...
- bzoj 2865 字符串识别——后缀数组
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2865 做出 ht[ ] 之后,sa[ ] 上每个位置和它前面与后面取 LCP ,其中较大的长 ...
- POJ1961:Period
浅谈\(KMP\):https://www.cnblogs.com/AKMer/p/10438148.html 题目传送门:http://poj.org/problem?id=1961 根据研究发现, ...
- 微信 unionid 获取 解密数据
1.申请注册微信开放平台 open.weixin.qq.com 2.绑定公众号或者小程序到微信开放平台 3.微信公众号的话,使用微信网页授权获取 unionid https://mp.weixin. ...
- 通过html字符串连接组合并调用javascript函数
----通过字符串连接并调用javascript函数-- var t_html = $("#Photo").html(); var n_html = "<a id= ...
- setTimeout传参
unction test(s) { alert(s); } window.setTimeout(function(){test('str');},1000); 这样就可以了...为什么是这样呢.因为s ...
- spring bean id重复覆盖的问题解决
问题: 当我们的web应用做成一个大项目之后,里面有很多的bean配置,如果两个bean的配置id是一样的而且实现类也是一样的,例如有下面两份xml的配置文档: beancontext1.xml &l ...