添加事物

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 事物的更多相关文章

  1. LoadRunner去除事物中的程序的执行时间

    大家在性能测试过程中,经常会用到程序处理或组织数据,以达到一定的测试目的,但是程序本身执行会消耗一些时间,这部分消耗的时间是包含在响应时间里面,此时,响应时间=正常响应时间+程序执行消耗时间.那么如何 ...

  2. LoadRunner中响应时间与事物时间详解

    1. 响应时间 事务是指用户在客户端做一种或多种业务所需要的操作集,通过事务函数可以标记完成该业务所需要的操作内容:另一方面事务可以用来统计用户操作的响应时间,事务响应时间是通过记录用户请求的开始时间 ...

  3. LoadRunner通过验证参数判断事物的成功与失败

    if(atoi(lr_eval_string("{Param_DiscountID}")) > 0){ //lr_message("多机多酒:%s",lr ...

  4. loadrunner总体使用篇

    为什么要进行性能测试呢?  有些问题是只有在大并发或者压力测试下才会暴露出来的,在平常的公司内部测试中,感觉一切都是正常的,但是把服务放到生产线上,例如某个时刻突然有很多的用户要向我们的服务发送请求, ...

  5. 转 LoadRunner 技巧之 IP欺骗 (推荐)

    IP欺骗也是也loadrunner自带的一个非常有用的功能. 需要使用ip欺骗的原因: 1.当某个IP的访问过于频繁,或者访问量过大是,服务器会拒绝访问请求,这时候通过IP欺骗可以增加访问频率和访问量 ...

  6. loadrunner的基本操作

    一.遗留问题: 1.controller中,到设置的时间后,仍然在运行: 2.如何对多个用例的结果进行分析,找到系统可以承受的最佳的用户数量点: 3.vuser与实际的用户访问数量是一回事吗?比如vu ...

  7. LoadRunner ---思考时间设置

    用户访问某个网站或软件,一般不会不停地做个各种操作,例如一次查询,用户需要时间查看查询的结果是否是自己想要的.例如一次订单提交,用户需要时间核对自己填写的信息是否正确等. 也就是说用户在做某些操作时, ...

  8. LoadRunner测试50人同时登陆下单

    LoadRunner测试50人同时登陆下单 一.LoadRunner简介 LoadRunner,是一种预测系统行为和性能的负载测试工具.通过以模拟上千万用户实施并发负载及实时性能监测的方式来确认和查找 ...

  9. LoadRunner - 当DiscuzNT遇上了Loadrunner(下) (转发)

    当DiscuzNT遇上了Loadrunner(下) 在之前的两篇文章中,基本上介绍了如何录制脚本和生成并发用户,同时还对测试报告中的几个图表做了简单的说明.今天这篇文章做为这个系列的最后一篇,将会介绍 ...

随机推荐

  1. gcc编译 汇编 选项

    gcc生成main.out的步骤分解:<blockquote>main.c-----(-S 编译)-------->main.s-------(-c 汇编)------->ma ...

  2. 51nod 1089 最长回文子串 V2(Manacher算法)

    回文串是指aba.abba.cccbccc.aaaa这种左右对称的字符串. 输入一个字符串Str,输出Str里最长回文子串的长度. 收起   输入 输入Str(Str的长度 <= 100000) ...

  3. [樹莓派]用mkusb来制作U盘启动安装Ubuntu 15.04

    之前實踐過這文章的描述,還可以成功:http://www.linuxdiyf.com/linux/12719.html,轉記錄餘下: 官方英文文档,教你在Ubuntu 15.04下使用mkusb来制作 ...

  4. PHP数组排序和按数量分割

    用PHP自带array_multisort函数排序 <?php     $data = array();    $data[] = array('volume' => 67, 'editi ...

  5. poj1011---DFS

    题目的大意是给了你有限个棍子以及每个棍子的长度,而且所有的棍子都是由有限个长度相同的棍子截断得到的,让你求被截棍子的最小长度 搜索剪枝神题,做的我够呛 提供一个比较好的解题报告  http://www ...

  6. week-02 线性表

    一.PTA实验作业 题目1:顺序表 7-1 最长连续递增子序列 1. 设计思路 定义结构体List,定义数组Data[maxsize]表示顺序表元素,变量Position表示位置,变量Length表示 ...

  7. js大法处理富文本输入

  8. nginx 的第三方模块ngx_http_accesskey_module 来实现下载文件的防盗链步骤(linux系统下)

    nginx 的第三方模块ngx_http_accesskey_module 来实现下载文件的防盗链步骤(linux系统下),安装Nginx和HttpAccessKeyModule模块(参考LNMP环境 ...

  9. innodb事务日志详解

    首先看InnoDB的缓存和文件的关系图如下: InnoDB事务日志功能介绍 InnoDB使用日志来减少提交事务时的开销.因为日志中已经记录了事务,就无须在每个事务提交时把缓冲池的脏块刷新(flush) ...

  10. CCPC2018-湖南全国邀请赛 G String Transformation

    G.String Transformation 题目描述 Bobo has a string S = s1 s2...sn consists of letter a , b and c . He ca ...