添加事物

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. 旧书重温:0day2【11】第6章 狙击windows的异常处理

    昨晚经过一番努力,又把第六章的内容温习了一遍! 随手,做了一个实验!狙击windows的异常处理, 顺便也把过程记录了下来!省事!(有图) 今早,论坛一直无法打开! 就推迟到了现在! 哈哈 正题: 第 ...

  2. HTTP浅析

    引言 HTTP是一个属于应用层的面向对象的协议,由于其简捷.快速的方式,适用于分布式超媒体信息系统.它于1990年提出,经过几年的使用与发展,得到不断地完善和扩展.目前在WWW中使用的是HTTP/1. ...

  3. WPF导学目录

    很早就知道WPF这个东西,做项目中没用到,也就没去整理学习.作为winForm的升级版,未来windows桌面应用程序的趋势,有些公司招聘需求中也会提到熟悉WPF,于是就整理学习了一下WPF. 主要参 ...

  4. 转载 matlab矩阵数组常用操作

    一. length             返回矩阵最长维的的长度    ndims       返回维数          numel      返回矩阵元素个数size               ...

  5. git撤销各种状态下的操作

    使用Git时会出现各种各样的问题,下面是几种情况下怎么反悔的操作 一,未加入缓存区,撤销文件修改 git checkout -- file 二,已加入缓存区,撤销文件提交 git reset HEAD ...

  6. nginx time_wait 较多优化

    1. 查看命令   netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'   结果 ESTABLISHED 22 F ...

  7. vs2015 c++ _findnext 报错

    定位 _findnext(hFile,&fileinfo) 报错. 错误 :0x00007FFC70CB0B2D (ntdll.dll)处(位于 Cutton_Dlg.exe 中)引发的异常: ...

  8. Linux bash shell 入门

    https://www.cnblogs.com/cosiray/archive/2012/03/02/2377099.html

  9. mysql数据库备份脚本

    mysql数据库备份脚本 mysql数据库分库备份脚本:[root@localhost tmp]# cat mysql.sh #!/bin/bash USER=root PASSWORD=joy4yo ...

  10. java.sql.SQLException: 无法转换为内部表示

    1. 我出这个错代码:wfef.setRow_num(rs.getInt(rs.getInt(12))); 2. 分析:rs.getInt(12)  得到的是int类型,rs.getInt(rs.ge ...