lr_start_timer,lr_get_transaction_duration,lr_get_transaction_wasted_time函数使用总结

lr_start_timer:

函数的功能:

为了计算时间更加精确,可以用这个函数去掉LR自身的检查点所浪费的时间。如text check and image time

 

Action()
{
double time_elapsed;
merc_timer_handle_t timer;web_url("487989.html","URL=http://www.cnblogs.com/tester2test/archive/2006/08/28/487989.html","Resource=0","RecContentType=text/html","Referer=","Snapshot=t2.inf","Mode=HTML",LAST);lr_start_transaction("download");timer = lr_start_timer();Download("http://files.cnblogs.com/tester2test/xncssj.pdf", "http://www.cnblogs.com/tester2test/archive/2006/08/28/487989.html", "c:\\test.pdf", "wb");time_elapsed = lr_end_timer(timer);lr_wasted_time(time_elapsed * 1000);lr_end_transaction("download", LR_AUTO);return 0;
}

 

double time_elapsed, duration, waste;merc_timer_handle_t timer;lr_start_transaction("sampleTrans");web_url("index.htm","URL=http://localhost/index.htm","TargetFrame=","Resource=0","RecContentType=text/html","Referer=","Snapshot=t1.inf","Mode=HTML",LAST);timer = lr_start_timer();/* Do some checks the duration of whichis not to be included in the transaction. */web_image_check("ImgCheck1","src=index_files/image002.jpg",LAST);web_image_check("ImgCheck2","src=index_files/planets.gif",LAST);// How long did the tests take in seconds.
time_elapsed = lr_end_timer(timer);// Convert to millisecond.s
waste = time_elapsed * 1000;/* Remove the time the checks took fromthe transaction. */lr_wasted_time(waste);lr_end_transaction("sampleTrans", LR_AUTO);

 

 

lr_get_transaction_duration:返回事件执行到此处所用的时间

C 语言:double lr_get_transaction_duration(const char *transaction);Example:Action(){double Connect_trans_time;  // 接收函数返回值double Move_trans_time;lr_start_transaction("Connect_trans");lr_create_socket("socket0","TCP","RemoteHost = localhost:1111",LrsLastArg);  // IP和端口仅供参考//......(others)// 调用 lr_get_transaction_duration() 函数
Connect_trans_time = lr_get_transaction_duration("Connect_trans");lr_end_transaction("Connect_trans",LR_AUTO);lr_start_transaction("Move_trans");//......(others)
Move_trans_time = lr_get_transaction_duration("Move"); // 获取 Move_trans 事件执行到此处所用时间
lr_end_transaction("Move_trans",LR_AUTO);lr_output_message("The duration up to the <Connect_trans_time> is %f seconds",Connect_trans_time);lr_output_message("The duration up to the <Move_trans_time> is %f seconds",Move_trans_time);return 0;}Action.c(1259): Notify: Transaction "Connect_trans" ended with "Pass" status (Duration:1.1164)Action.c(1717): Notify: Transaction "Move_trans" ended with "Pass" status (Duration: 0.4036)Action.c(1719): The duration up to the <Connec_trans_time> is 1.116110 secondsAction.c(1721): The duration up to the <Move_trans_time> is 0.403350 seconds根据业务操作分离出脚本中的两个事件,Connect(连接DB)操作和Move(拖屏)操作,Contro中运行结果显示“拖屏”消耗时间远大于“连接”消耗时间,这同程序设计与实现的实际情况不符。所以调用了【lr_get_transaction_duration();】函数来验证事件的运行时间,进一步分析性能问题原因所在。验证结果已证明拖屏操作消耗时间的确小于连接操作消耗时间。


 

lr_get_transaction_wasted_time:函数用于返回指定事物当前的损耗时间(wasted time)。

函数统计的是事物开始到此函数位置,lr自身的浪费时间(如:执行关联、检查点等函数的时间)。
 
损耗时间通常是指脚本消耗在为了支持测试分析而做的操作时间。这些操作不会被实际用户所执行。
 
例如一些循环赋值操作或插入检查点操作。消耗的时间有lr_wasted_time函数在

 
lr_get_transaction_wasted_time函数之前移除了,移除后才得到对应的结果。

函数语法结果

double lr_get_transaction_wasted_time (const char * transaction);

参数 transaction 为事物名称

 
使用lr_get_transaction_wansted_time
函数必须注意,

一它只能对当前运行状态的事物才能返回大于等于0的结果,否则返回小于0的结果。

二是他使用之前应调用lr_wansted_time 函数移除过损耗时间
wasted time,否则lr_get_transaction_wansted_time将返回0。

 

附代码如下:timer=lr_start_timer();web_find("web_find","what=9000000022",LAST);time_elapsed=lr_end_timer(timer);lr_output_message("find时间为:%f",time_elapsed);lr_output_message("事务当前的损耗时间为:%f",lr_get_transaction_wasted_time("登陆"));  //先算出从事务开始到现在lr自身的浪费时间。因为无损耗,所以,lr_get_transaction_wasted_time= 0s 。//使用lr_wasted_time()函数为事物添加浪费时间lr_wasted_time(time_elapsed*1000);     //Wasted Time=lr自身的浪费时间(0s)+第三方时间的开销(time_elapsed*1000s))lr_output_message("find时间为:%f,事务当前的损耗时间为:%f",time_elapsed,lr_get_transaction_wasted_time("登陆"));

 

 

Action()
{int i, baseIter = 1000; char dude[1000]; double wasteTime, actualElapsedTime; merc_timer_handle_t MasterT, timer; // Examine the total elapsed time of the action 
MasterT = lr_start_timer(); //Start transaction 
lr_start_transaction("Demo"); // Create some elapsed time for the transaction for (i=0; i< (10 * baseIter); ++i) sprintf(dude, "This is the way we create elapsed time artificially = %d", i); // Add some think time 
lr_think_time(0.5); // Create some wasted time and record it with timer 
timer = lr_start_timer(); for (i=0; i< (5 * baseIter); ++i) sprintf(dude, "This is the way we waste time in a script = %d", i); wasteTime = lr_end_timer(timer); lr_output_message("User created waste time = %lf", wasteTime); lr_output_message("Before lr_waste_time: Duration = %lf - Waste = %lf",         lr_get_transaction_duration("Demo"), lr_get_transaction_wasted_time("Demo")); /* Convert Timer in seconds to wasted time in milliseconds and add to internally generated waste time */ wasteTime *= 1000; lr_wasted_time(wasteTime); lr_output_message("After lr_waste_time: Duration = %lf - Waste = %lf", lr_get_transaction_duration("Demo"), lr_get_transaction_wasted_time("Demo")); lr_output_message("Think time = %lf", lr_get_transaction_think_time("Demo")); lr_end_transaction("Demo", LR_AUTO); actualElapsedTime = lr_end_timer(MasterT); lr_output_message("Total Elapsed time for Action = %lf", actualElapsedTime);return 0;
}结果:
Starting iteration 1.
Starting action Action.
Action.c(17): Notify: Transaction "Demo" started.
Action.c(45): User created waste time = 15.768059
Action.c(47): Before lr_waste_time: Duration = 65.147478 - Waste = 0.000000
Action.c(61): After lr_waste_time: Duration = 65.153110 - Waste = 15.768000
Action.c(67): Think time = 0.000000
Action.c(71): Notify: Transaction "Demo" ended with "Pass" status (Duration: 65.1589 Wasted Time: 15.7680).
Action.c(75): Total Elapsed time for Action = 65.170579
Ending action Action.
Ending iteration 1.

 

 

 lr_get_transaction_wasted_time函数用于返回指定事物当前的损耗时间(wasted time)。     损耗时间通常是指脚本消耗在为了支持测试分析而做的操作时间。这些操作不会被实际用户所执行。     例如一些循环赋值操作或插入检查点操作。消耗的时间有lr_wasted_time函数在
  lr_get_transaction_wasted_time函数之前移除了,移除后才得到对应的结果。
  函数语法结果
  double lr_get_transaction_wasted_time (const char * transaction);
  参数 transaction 为事物名称
  使用lr_get_transaction_wansted_time 函数必须注意,一它只能对当前运行状态的事物才能返回大于等于0的结果,否则返回小于0的结果。二是他使用之前应调用lr_wansted_time 函数移除过损耗时间 wasted time,否则lr_get_transaction_wansted_time将返回0。

帮助例子程序:

WasteTime()

{

       int i, baseIter = 1000;

       char dude[1000];

       double wasteTime, actualElapsedTime;

       merc_timer_handle_t MasterT, timer;

       // Examine the total elapsed time of the action

       MasterT = lr_start_timer();

       //Start transaction

       lr_start_transaction("Demo");

       // Create some elapsed time for the transaction

       for (i=0; i< (10 * baseIter); ++i)

      sprintf(dude,

        "This is the way we create elapsed  time artificially = %d", i);                 

       // Add some think time

       lr_think_time(0.5);

       // Create some wasted time and record it with timer

       timer =lr_start_timer();

       for (i=0; i< (5 * baseIter); ++i)

                     sprintf(dude,

                            "This is the way we waste time in  a script. = %d", i);

       wasteTime =lr_end_timer(timer);

       lr_output_message("User created waste time = %lf",  wasteTime);

       lr_output_message("Before lr_waste_time: Duration = %lf  - Waste = %lf",              

         lr_get_transaction_duration("Demo"),

        lr_get_transaction_wasted_time("Demo"));

       /* Convert Timer in seconds to wasted time in  milliseconds

        and add to internally generated waste time */

       wasteTime *= 1000;

       lr_wasted_time(wasteTime);

       lr_output_message("After lr_waste_time: Duration = %lf  - Waste = %lf",

        lr_get_transaction_duration("Demo"),

       lr_get_transaction_wasted_time("Demo"));

       lr_output_message("Think time = %lf",

              lr_get_transaction_think_time("Demo"));

       lr_end_transaction("Demo", LR_AUTO);

       actualElapsedTime = lr_end_timer(MasterT);

       lr_output_message("Total Elapsed time for Action =  %lf",

              actualElapsedTime);

       return 0;

}

Vuser Output log file 输出日志

Note there is no difference between the transaction duration  before and after the call to lr_waste_time

WasteTime.c(28): User created waste time = 0.031250       

WasteTime.c(32): Before lr_waste_time: Duration = 0.609375 -  Waste = 0.000000       

WasteTime.c(40): After lr_waste_time: Duration = 0.625000 -  Waste = 0.031000       

WasteTime.c(44): Think time = 0.500000       

WasteTime.c(47): Notify: Transaction Demo ended with Pass  status (Duration: 0.6406 Think Time: 0.5000 Wasted Time: 0.0310).       

WasteTime.c(50): Total Elapsed time for Action = 0.640625        

Analysis: Average Response Time Raw Data

Note that the Transaction Response Time for "Demo" is 0.61.  This is the Duration from the Vuser log (0.6406) minus the Wasted Time (  0.0310).

Transaction End Status
Transaction Father Tree path
Scenario Elapsed Time
Transaction Response Time
Transaction Name
Pass
NONE
4.843
0
vuser_init_Transaction
Pass
WasteTime_Transaction
5.514
0.61
Demo
Pass
NONE
5.53
0.625
WasteTime_Transaction
Pass
NONE
5.53
0
vuser_end_Transaction

 
 

转载于:https://www.cnblogs.com/qmfsun/p/4481395.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/376007.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

c可变参数

本文为个人学习笔记&#xff0c;仅供个人学习、复习使用。参考链接&#xff1a;链接1、链接2在c语言中&#xff0c;我们可以定义这样的函数&#xff0c;函数带有可变数量的参数。 int func(int num,...){ . . . } int main(){func(2,2,3); }1、要注意定义函数时函数的形式&…

dz打不开plugin. php,Discuz!应用中心打不开空白的解决方法

近期&#xff0c;很多使用Discuz!程序建论坛的站长都会发现&#xff0c;Discuz!后台的应用中心打不开了。这二天Discuz!终于给出了原因&#xff1a;十分抱歉的通知您&#xff0c;由于资源和人力投入问题&#xff0c;我们已经关闭了 www.discuz.net 的发言权限&#xff0c;但是历…

编程习题05

1、给定一个数组a[N],我们希望构造数组b[N]&#xff0c;其中b[i]a[0]*a[1]*...*a[N-1]/a[i]。在构造过程&#xff1a;不允许使用除法&#xff1b;要求O(1)空间复杂度和O(n)时间复杂度&#xff1b;除遍历计数器与a[N] b[N]外&#xff0c;不可使用新的变量(包括栈临时变量、对空间…

ECshop安装及报错解决方案总结

一、安装ECshop ECShop是一款B2C独立网店系统 &#xff0c;适合企业及个人快速构建个性化网上商店。系统是基于PHP语言及MYSQL数据库构架开发的跨平台开源程序。2006年3月推出以来1.0版以来&#xff0c;受到市场的检验&#xff0c;广受好评。 1.安装准备 ECshop最新版本为2.7.3…

Command mysql 中文,MySQL Command Line[mysql命令行常用命令]_MySQL

bitsCN.comMySql下载地址&#xff1a;www.mysql.org第一招、mysql服务的启动和停止net stop mysqlnet start mysql第二招、登陆mysqlmysql -u用户名-p用户密码mysql -uroot -p&#xff0c; 回车後提示你输入密码&#xff0c;输入12345&#xff0c;然後回车即可进入到mysql中了&…

setTimeout里如果有$(this),$(this)指的是谁?

$(".next").click(function(){ setTimeout(function(){$(this).addClass("gray");//指向的是window 而不是$(".next") },1000); })转载于:https://www.cnblogs.com/xchlsl/p/4484762.html

数据结构--数组实现线性表

线性表&#xff1a;由同类型数据元素构成的有序序列的线性结构 编译环境&#xff1a;Dev-C 结构实现&#xff1a; struct LNode {ElementType Data[MAXSIZE];int last; }; 主要操作函数&#xff1a; List MakeEmpty();//初始化一个空表ElementType FindKth(int k, List L);//根…

Codeforces Round #241 (Div. 2) A. Guess a number!

题目链接 题意 &#xff1a; 就是猜数游戏&#xff0c;根据给定的操作&#xff0c;让你输出一个符合条件的。 思路 &#xff1a; 这个题好玩儿&#xff0c;设置两个变量&#xff0c;一个找符合条件的数的上限&#xff0c;一个找下限&#xff0c;再判断一下。 1 #include <st…

php中嵌套调用的原理,嵌套调用

## 嵌套调用- 模块与模块之间的相互调用(相对路径)- 项目和项目之间的相互调用(绝对路径)- 也可以写一个通用模块就可以大面积使用&#xff0c;减少代码维护成本- 或许可以实现一些神奇的效果#### 示例代码设置文件/html/www/demo/tpl/tpl.blade.php内容如下~~~这是最顶端模块{…

SET-UID程序漏洞实验

20125102 一、实验描述 Set-UID 是Unix系统中的一个重要的安全机制。当一个Set-UID程序运行的时候&#xff0c;它被假设为具有拥有者的权限。例如&#xff0c;如果程序的拥有者是root&#xff0c;那么任何人运行这个程序时都会获得程序拥有者的权限。Set-UID允许我们做许多很有…

统计文件中有多少个单词amp;c语言实现

假设文件中的单词都是字母的组合&#xff0c;且单词间用空格或者“."区分。实验环境&#xff1a;Dev-C#include<stdio.h> #include<stdlib.h>int main(){FILE *fp;int i;int fr;long fsize;int word0;int sum0;char filename[20];char *buffer;printf("要…

oracle mul,汇编语言乘指令 MUL、IMUL的具体使用

MUL: 无符号乘;影响 OF、CF 标志位;指令格式:;MUL r/m ;参数是乘数;如果参数是 r8/m8, 将把 AL 做乘数, 结果放在 AX;如果参数是 r16/m16, 将把 AX 做乘数, 结果放在 EAX;如果参数是 r32/m32, 将把 EAX 做乘数, 结果放在 EDX:EAX当乘积的高半部分(AH、DX、EDX、RDX)中存有结…

java实验二

课程&#xff1a;Java程序设计 班级&#xff1a; 1352 姓名&#xff1a;黄卫   学号&#xff1a;20135221 成绩&#xff1a; 指导教师&#xff1a;娄嘉鹏 实验日期&#xff1a;2015.05.05 实验密级&#xff1a; 预…

两数之和c语言实现

题目描述&#xff1a;给定一个整数数组和一个目标值&#xff0c;找出数组中和为目标值的两个数。你可以假设每个输入只对应一种答案&#xff0c;且同样的元素不能被重复利用。示例:给定 nums [2, 7, 11, 15], target 9因为 nums[0] nums[1] 2 7 9 所以返回 [0, 1]解题思路…

【Linux】正确的关机方法

1&#xff09;shutdown命令 我们较常使用的是shutdown这个命令&#xff0c;这个命令可以安全地关闭或重启Linux系统&#xff0c;它在系统关闭之前给系统上的所有登录用户提示一条警告信息。该命令还允许用户指定一个时间参数&#xff0c;可以是一个精确的时间&#xff0c;也可以…

oracle 存储过程写文件,Oracle写本地文件

Oracle写本地文件是指写到运行Oracle的主机上&#xff0c;而不是运行该脚本的机器上。说起来有点拗口&#xff0c;实际上就是无论在哪里执行这个过程&#xff0c;生成的文件始终都是在服务器上的。下面过程实现了这个功能&#xff1a;logdir是指文件存放路径。有Oracle的direct…

两数相加c语言实现

给定两个非空链表来表示两个非负整数。位数按照逆序方式存储&#xff0c;它们的每个节点只存储单个数字。将两数相加返回一个新的链表。你可以假设除了数字 0 之外&#xff0c;这两个数字都不会以零开头。示例&#xff1a;输入&#xff1a;(2 -> 4 -> 3) (5 -> 6 -&g…

jQuery获取Select选择的Text和Value

一、 jQuery获取Select选择的Text和Value:语法解释&#xff1a; $("#select_id").change(function(){//code...}); //为Select添加事件&#xff0c;当选择其中一项时触发varcheckText$("#select_id").find("option:selected").tex…

jquery实现导航栏鼠标点击后实行背景高亮,点击离开恢复(超级简单!!!!)...

昨天才写了一个方法&#xff0c;今天发现一个更简单的。 html&#xff1a; <!DOCTYPE html> <html> <head lang"en"><meta charset"UTF-8"><title></title> </head> <body> <div class"dianji&qu…

Linux怎么处理binray文件,Linux下如何反汇编arm raw binary文件

有一个arm elf文件经过objcopy -O binary 命令处理生成bin文件进行反汇编:指令1&#xff1a;arm_v5t_le-objdump -b binary -m armv5te -D u-boot.bin|head指令2&#xff1a;arm-linux-objdump -D -b binary test.bin --architecturearm > /tmp/raw.txthttp://linux.chi…