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(下) 在之前的两篇文章中,基本上介绍了如何录制脚本和生成并发用户,同时还对测试报告中的几个图表做了简单的说明.今天这篇文章做为这个系列的最后一篇,将会介绍 ...
随机推荐
- How to use NSRequest in Delphi XE4
//Demo How to use NSRequest..procedure TiOSWebBrowserService.DoNavigate(const URL: string);var NewUR ...
- uid
var uid = 0 function nextUid() { return ++uid }
- bzoj 5369 最大前缀和
Written with StackEdit. Description 小\(C\)是一个算法竞赛爱好者,有一天小\(C\)遇到了一个非常难的问题:求一个序列的最大子段和. 但是小\(C\)并不会做这 ...
- 转载(原标题:网站再遭新威胁 Struts2又曝高危漏洞啦)
自从著名J2EE框架Apache Struts2被曝出可被远程攻击者利用的执行漏洞后,关于Struts2的安全性便广受关注.近日,安全研究人员则再次发现了Struts2存在远程代码执行的漏洞,Stru ...
- 剑指offer-第六章面试中的各项能力之总结
- C# 程序部署、调试时间长的解决办法
最近在做数控折弯机项目时,VS2008环境下采用C#..NET Compact Framework开发WinCE.Windows Mobile程序时,编译项目非常慢,看着进度条慢慢刷,有时候需要几分钟 ...
- Android蓝牙UUID简要
UUID是"Universally Unique Identifier"的简称,通用唯一识别码的意思.对于蓝牙设备,每个服务都有通用.独立.唯一的UUID与之对应.也就是说,在同一 ...
- Angular2配置文件详解
初学接触Angular2的时候,通过ng new your-project-name 命令生成一个工程空壳,本文来介绍下每个文件的作用及含义. 先来看看src的文件目录: 文件详解 File 文件 P ...
- Ubuntu15.10下Hadoop2.6.0伪分布式环境安装配置及Hadoop Streaming的体验
Ubuntu用的是Ubuntu15.10Beta2版本,正式的版本好像要到这个月的22号才发布.参考的资料主要是http://www.powerxing.com/install-hadoop-clus ...
- python3之scrapy安装使用
需要安装的包 pip install scrapy selenium 可能需要卸载重装的模块 lxml cryptography cffi pypiwin32 pip uninstall xx ...