去除程序执行的两种方式:

1.通过一个事务:在需要消除的代码段,使用lr_wasted_time(wasteTime);

querySubmit()
{ char newStr4[10000]=""; int num4;//获取fid、roomid的个数 double wasteTime,waste; //定义变量 merc_timer_handle_t timer; lr_vuser_status_message( "当前用户名:%s,迭代次数:%d",lr_eval_string("{fname}"),++iteration ); lr_convert_string_encoding( lr_eval_string("{building}"),LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"UnicodeString" ); //此时building是一个汉字列表的参数,把它转换为utf-8,存入UnicodeString参数中 lr_save_string( lr_eval_string("{UnicodeString}"),"building" ); //把UnicodeString参数的值又覆盖回building参数,前2步相当于完成了building参数的汉字到utf-8的转换 web_convert_param("building","SourceEncoding=PLAIN","TargetEncoding=URL",LAST); //这一步把building参数从utf-8又转换到url编码 lr_convert_string_encoding( lr_eval_string("{gardenid}"),LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"UnicodeString" ); //此时gardenid是一个汉字列表的参数,把它转换为utf-8,存入UnicodeString参数中 lr_save_string( lr_eval_string("{UnicodeString}"),"gardenid" ); //把UnicodeString参数的值又覆盖回gardenid参数,前2步相当于完成了gardenid参数的汉字到utf-8的转换 web_convert_param("gardenid","SourceEncoding=PLAIN","TargetEncoding=URL",LAST); //这一步把gardenid参数从utf-8又转换到url编码 lr_convert_string_encoding( lr_eval_string("{roomNo}"),LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"UnicodeString" ); //此时roomNo是一个汉字列表的参数,把它转换为utf-8,存入UnicodeString参数中 lr_save_string( lr_eval_string("{UnicodeString}"),"roomNo" ); //把UnicodeString参数的值又覆盖回roomNo参数,前2步相当于完成了roomNo参数的汉字到utf-8的转换 web_convert_param("roomNo","SourceEncoding=PLAIN","TargetEncoding=URL",LAST); //这一步把roomNo参数从utf-8又转换到url编码 // lr_output_message("roomNo的Url编码=%s", lr_eval_string("{roomNo}")); web_set_max_html_param_len("1000000"); //设置关联参数接收最大的字节数 web_reg_save_param_ex(
"ParamName=fid4",
"LB=id\":\"",
"RB=\",",
"NotFound=warning",
"Ordinal=All",
SEARCH_FILTERS,
"Scope=Body",
"RequestUrl=*/queryData*",
LAST); web_reg_save_param_ex(
"ParamName=roomid4",
"LB=roomId\":\"",
"RB=\",",
"NotFound=warning",
"Ordinal=All",
SEARCH_FILTERS,
"Scope=Body",
"RequestUrl=*/queryData*",
LAST); lr_rendezvous("设置提交集合点"); lr_start_transaction("查询开始事务"); web_custom_request("queryData_4",
"URL=http://0755.qfang.com/qfang-broker/house/search/queryData",
"Method=POST",
"TargetFrame=",
"Resource=0",
"RecContentType=application/json",
"Referer=http://0755.qfang.com/qfang-broker/house/search",
"Snapshot=t33.inf",
"Mode=HTML",
"EncType=application/x-www-form-urlencoded; charset=UTF-8",
"Body=houseState='RENT_SALE'%2C'RENT'%2C'SALE'%2C'OUTSIDE_SALED'%2C'COMPANY_SALED'%2C'OUTSIDE_RENTED'%2C'COMPANY_RENTED'%2C'STOP'%2C'DATA'&garden='{gardenid}'&building={building}&roomNo={roomNo}&crTypeValue=APARTMENT&subClassType='APARTMENT'&roomPattern='{roomPattern}'&permission=1&orgId={orgid}&searchPage=new&sqlQuery=false&curTab=ALL&changeSearchCondition=true",
LAST); timer=lr_start_timer(); //timer开始:创建计时器,返回值是计时器标志,统计for循环花费的时间 if (strcmp(lr_eval_string("{fid4}")," ")==0)
{
// lr_output_message("该条记录无法匹配到精确的楼盘信息!"); strcpy(newStr4,""); lr_save_string( newStr4,"lastStr4" ); // lr_output_message("newStr4的值:%s", newStr4); }
else
{
for(num4 =1;num4<=atoi(lr_eval_string("{roomid4_count}"));num4++) { sprintf( fidVar4,"{fid4_%d}",num4 ); //将num变量保存到fidVar中, sprintf( fidValue4,"%s",lr_eval_string(fidVar4) ); sprintf( roomidVar4,"{roomid4_%d}",num4 ); //将num变量保存到fidVar中, sprintf( roomidValue4,"%s",lr_eval_string(roomidVar4) ); lr_output_message("fid4_%d的值:%s", num4, fidValue4); lr_output_message("roomid4_%d的值:%s", num4, roomidValue4); strcat( fidValue4,"_" ); strcat( fidValue4,roomidValue4 ); // lr_output_message("%s", fidValue4); if(num4 != atoi(lr_eval_string("{roomid4_count}"))) { strcat( fidValue4,"," ); } strcat( newStr4,fidValue4 ); } lr_save_string( newStr4,"lastStr4" ); // lr_output_message("newStr4的值:%s", newStr4); // lr_output_message("拼接后的整体字符串lastStr4的值:%s", lr_eval_string("{lastStr4}")); }   waste = lr_end_timer(timer);  //停止timer wasteTime=waste * 1000;  lr_wasted_time(wasteTime); web_submit_data("getNewFollows_4",
"Action=http://0755.qfang.com/qfang-broker/house/follow/getNewFollows",
"Method=POST",
"TargetFrame=",
"RecContentType=application/json",
"Referer=http://0755.qfang.com/qfang-broker/house/search",
"Snapshot=t34.inf",
"Mode=HTML",
ITEMDATA,
"Name=roomIds", "Value={lastStr4}", ENDITEM,
LAST); lr_end_transaction("查询开始事务", LR_AUTO); return 0; }

方案二:通过在父事务中插入两个子事务

querySubmit()
{ char newStr4[10000]=""; int num4;//获取fid、roomid的个数 lr_vuser_status_message( "当前用户名:%s,迭代次数:%d",lr_eval_string("{fname}"),++iteration ); lr_convert_string_encoding( lr_eval_string("{building}"),LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"UnicodeString" ); //此时building是一个汉字列表的参数,把它转换为utf-8,存入UnicodeString参数中 lr_save_string( lr_eval_string("{UnicodeString}"),"building" ); //把UnicodeString参数的值又覆盖回building参数,前2步相当于完成了building参数的汉字到utf-8的转换 web_convert_param("building","SourceEncoding=PLAIN","TargetEncoding=URL",LAST); //这一步把building参数从utf-8又转换到url编码 lr_convert_string_encoding( lr_eval_string("{gardenid}"),LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"UnicodeString" ); //此时gardenid是一个汉字列表的参数,把它转换为utf-8,存入UnicodeString参数中 lr_save_string( lr_eval_string("{UnicodeString}"),"gardenid" ); //把UnicodeString参数的值又覆盖回gardenid参数,前2步相当于完成了gardenid参数的汉字到utf-8的转换 web_convert_param("gardenid","SourceEncoding=PLAIN","TargetEncoding=URL",LAST); //这一步把gardenid参数从utf-8又转换到url编码 lr_convert_string_encoding( lr_eval_string("{roomNo}"),LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"UnicodeString" ); //此时roomNo是一个汉字列表的参数,把它转换为utf-8,存入UnicodeString参数中 lr_save_string( lr_eval_string("{UnicodeString}"),"roomNo" ); //把UnicodeString参数的值又覆盖回roomNo参数,前2步相当于完成了roomNo参数的汉字到utf-8的转换 web_convert_param("roomNo","SourceEncoding=PLAIN","TargetEncoding=URL",LAST); //这一步把roomNo参数从utf-8又转换到url编码 web_set_max_html_param_len("1000000"); //设置关联参数接收最大的字节数 web_reg_save_param_ex(
"ParamName=fid4",
"LB=id\":\"",
"RB=\",",
"NotFound=warning",
"Ordinal=All",
SEARCH_FILTERS,
"Scope=Body",
"RequestUrl=*/queryData*",
LAST); web_reg_save_param_ex(
"ParamName=roomid4",
"LB=roomId\":\"",
"RB=\",",
"NotFound=warning",
"Ordinal=All",
SEARCH_FILTERS,
"Scope=Body",
"RequestUrl=*/queryData*",
LAST); // lr_think_time(16); lr_rendezvous("设置提交集合点"); lr_start_transaction("查询开始事务"); lr_start_sub_transaction("queryDate","查询开始事务"); web_custom_request("queryData_4",
"URL=http://0755.qfang.com/qfang-broker/house/search/queryData",
"Method=POST",
"TargetFrame=",
"Resource=0",
"RecContentType=application/json",
"Referer=http://0755.qfang.com/qfang-broker/house/search",
"Snapshot=t33.inf",
"Mode=HTML",
"EncType=application/x-www-form-urlencoded; charset=UTF-8",
"Body=houseState='RENT_SALE'%2C'RENT'%2C'SALE'%2C'OUTSIDE_SALED'%2C'COMPANY_SALED'%2C'OUTSIDE_RENTED'%2C'COMPANY_RENTED'%2C'STOP'%2C'DATA'&garden='{gardenid}'&building={building}&roomNo={roomNo}&crTypeValue=APARTMENT&subClassType='APARTMENT'&roomPattern='{roomPattern}'&permission=1&orgId={orgid}&searchPage=new&sqlQuery=false&curTab=ALL&changeSearchCondition=true",
LAST); lr_end_sub_transaction("queryDate",LR_AUTO); if (strcmp(lr_eval_string("{fid4}")," ")==0)
{
// lr_output_message("该条记录无法匹配到精确的楼盘信息!"); strcpy(newStr4,""); lr_save_string( newStr4,"lastStr4" ); }
else
{
for(num4 =1;num4<=atoi(lr_eval_string("{roomid4_count}"));num4++) { sprintf( fidVar4,"{fid4_%d}",num4 ); //将num变量保存到fidVar中, sprintf( fidValue4,"%s",lr_eval_string(fidVar4) ); sprintf( roomidVar4,"{roomid4_%d}",num4 ); //将num变量保存到fidVar中, sprintf( roomidValue4,"%s",lr_eval_string(roomidVar4) ); lr_output_message("fid4_%d的值:%s", num4, fidValue4); lr_output_message("roomid4_%d的值:%s", num4, roomidValue4); strcat( fidValue4,"_" ); strcat( fidValue4,roomidValue4 ); if(num4 != atoi(lr_eval_string("{roomid4_count}"))) { strcat( fidValue4,"," ); } strcat( newStr4,fidValue4 ); } lr_save_string( newStr4,"lastStr4" ); } lr_start_sub_transaction("getNewFollows","查询开始事务"); web_submit_data("getNewFollows_4",
"Action=http://0755.qfang.com/qfang-broker/house/follow/getNewFollows",
"Method=POST",
"TargetFrame=",
"RecContentType=application/json",
"Referer=http://0755.qfang.com/qfang-broker/house/search",
"Snapshot=t34.inf",
"Mode=HTML",
ITEMDATA,
"Name=roomIds", "Value={lastStr4}", ENDITEM,
LAST); lr_end_sub_transaction("getNewFollows",LR_AUTO); lr_end_transaction("查询开始事务", LR_AUTO); return 0; }

方法三:不添加任何消除时间方法:

querySubmit()
{ char newStr4[10000]=""; int num4;//获取fid、roomid的个数 lr_vuser_status_message( "当前用户名:%s,迭代次数:%d",lr_eval_string("{fname}"),++iteration ); lr_convert_string_encoding( lr_eval_string("{building}"),LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"UnicodeString" ); //此时building是一个汉字列表的参数,把它转换为utf-8,存入UnicodeString参数中 lr_save_string( lr_eval_string("{UnicodeString}"),"building" ); //把UnicodeString参数的值又覆盖回building参数,前2步相当于完成了building参数的汉字到utf-8的转换 web_convert_param("building","SourceEncoding=PLAIN","TargetEncoding=URL",LAST); //这一步把building参数从utf-8又转换到url编码 lr_convert_string_encoding( lr_eval_string("{gardenid}"),LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"UnicodeString" ); //此时gardenid是一个汉字列表的参数,把它转换为utf-8,存入UnicodeString参数中 lr_save_string( lr_eval_string("{UnicodeString}"),"gardenid" ); //把UnicodeString参数的值又覆盖回gardenid参数,前2步相当于完成了gardenid参数的汉字到utf-8的转换 web_convert_param("gardenid","SourceEncoding=PLAIN","TargetEncoding=URL",LAST); //这一步把gardenid参数从utf-8又转换到url编码 lr_convert_string_encoding( lr_eval_string("{roomNo}"),LR_ENC_SYSTEM_LOCALE,LR_ENC_UTF8,"UnicodeString" ); //此时roomNo是一个汉字列表的参数,把它转换为utf-8,存入UnicodeString参数中 lr_save_string( lr_eval_string("{UnicodeString}"),"roomNo" ); //把UnicodeString参数的值又覆盖回roomNo参数,前2步相当于完成了roomNo参数的汉字到utf-8的转换 web_convert_param("roomNo","SourceEncoding=PLAIN","TargetEncoding=URL",LAST); //这一步把roomNo参数从utf-8又转换到url编码 web_set_max_html_param_len("1000000"); //设置关联参数接收最大的字节数 web_reg_save_param_ex(
"ParamName=fid4",
"LB=id\":\"",
"RB=\",",
"NotFound=warning",
"Ordinal=All",
SEARCH_FILTERS,
"Scope=Body",
"RequestUrl=*/queryData*",
LAST); web_reg_save_param_ex(
"ParamName=roomid4",
"LB=roomId\":\"",
"RB=\",",
"NotFound=warning",
"Ordinal=All",
SEARCH_FILTERS,
"Scope=Body",
"RequestUrl=*/queryData*",
LAST); // lr_think_time(16); lr_rendezvous("设置提交集合点"); lr_start_transaction("查询开始事务"); web_custom_request("queryData_4",
"URL=http://0755.qfang.com/qfang-broker/house/search/queryData",
"Method=POST",
"TargetFrame=",
"Resource=0",
"RecContentType=application/json",
"Referer=http://0755.qfang.com/qfang-broker/house/search",
"Snapshot=t33.inf",
"Mode=HTML",
"EncType=application/x-www-form-urlencoded; charset=UTF-8",
"Body=houseState='RENT_SALE'%2C'RENT'%2C'SALE'%2C'OUTSIDE_SALED'%2C'COMPANY_SALED'%2C'OUTSIDE_RENTED'%2C'COMPANY_RENTED'%2C'STOP'%2C'DATA'&garden='{gardenid}'&building={building}&roomNo={roomNo}&crTypeValue=APARTMENT&subClassType='APARTMENT'&roomPattern='{roomPattern}'&permission=1&orgId={orgid}&searchPage=new&sqlQuery=false&curTab=ALL&changeSearchCondition=true",
LAST); if (strcmp(lr_eval_string("{fid4}")," ")==0)
{
// lr_output_message("该条记录无法匹配到精确的楼盘信息!"); strcpy(newStr4,""); lr_save_string( newStr4,"lastStr4" ); }
else
{
for(num4 =1;num4<=atoi(lr_eval_string("{roomid4_count}"));num4++) { sprintf( fidVar4,"{fid4_%d}",num4 ); //将num变量保存到fidVar中, sprintf( fidValue4,"%s",lr_eval_string(fidVar4) ); sprintf( roomidVar4,"{roomid4_%d}",num4 ); //将num变量保存到fidVar中, sprintf( roomidValue4,"%s",lr_eval_string(roomidVar4) ); lr_output_message("fid4_%d的值:%s", num4, fidValue4); lr_output_message("roomid4_%d的值:%s", num4, roomidValue4); strcat( fidValue4,"_" ); strcat( fidValue4,roomidValue4 ); if(num4 != atoi(lr_eval_string("{roomid4_count}"))) { strcat( fidValue4,"," ); } strcat( newStr4,fidValue4 ); } lr_save_string( newStr4,"lastStr4" ); } web_submit_data("getNewFollows_4",
"Action=http://0755.qfang.com/qfang-broker/house/follow/getNewFollows",
"Method=POST",
"TargetFrame=",
"RecContentType=application/json",
"Referer=http://0755.qfang.com/qfang-broker/house/search",
"Snapshot=t34.inf",
"Mode=HTML",
ITEMDATA,
"Name=roomIds", "Value={lastStr4}", ENDITEM,
LAST); lr_end_transaction("查询开始事务", LR_AUTO); return 0; }

lr计算程序执行消耗时间的比较:的更多相关文章

  1. golang 如何查看程序执行消耗时间

    写代码过程中,有时需要分析代码块的时间消耗. 本文介绍使用time包中的Since函数查看程序执行时间. package main import ( "fmt" "tim ...

  2. MSSQL的SQL语句独立执行消耗与线上执行消耗差异

    环境: SQL Server 2012 疑问:同样的一条语句,使用Profile跟踪出来的消耗与单独拿出来执行的消耗存在非常大的差距 语句如下: declare @str nvarchar(max) ...

  3. [fw]Linux系统使用time计算命令执行的时间

    Linux系统使用time计算命令执行的时间 当测试一个程序或比较不同算法时,执行时间是非常重要的,一个好的算法应该是用时最短的.所有类UNIX系统都包含time命令,使用这个命令可以统计时间消耗.例 ...

  4. MySql 简单统计查询消耗时间脚本

    MySql 简单统计查询消耗时间脚本 by:授客 QQ:1033553122 drop procedure if exists selectTime; delimiter; create proced ...

  5. C# .Net计算函数执行的时间

    C#计算函数执行的时间 protected void StopwatchTest() { System.Diagnostics.Stopwatch stopwatch = new System.Dia ...

  6. 在Linux下如何限制命令执行的时间?

    在Linux下如何限制命令执行的时间?两种解决方法,如下: 1: Linux命令——timeout 运行指定的命令,如果在指定时间后仍在运行,则杀死该进程.用来控制程序运行的时间. 2: comman ...

  7. sql语句执行的时间

    统计mysql里每条SQL语句执行的时间 收藏 CrazyHarry 发表于 2年前 阅读 3785 收藏 8 点赞 3 评论 3 Google.Github 双重认证前端课程,独家硅谷内容,每周直播 ...

  8. 如何使用FF的Firebug组件中的net工具查看页面元素加载消耗时间

    1.安装FF的Firebug组件:点击FF的Tools的Add-ons菜单,输入Firebug关键字,并选择合适的版本Install. 2.安装完毕后地址栏右边会出现一个小虫图标,右边还有一个下拉箭头 ...

  9. PHP获取PHP执行的时间

    php获取PHP执行的时间 <pre> //程序运行时间 $starttime = explode(' ',microtime()); //代码区域 //程序运行时间 $endtime = ...

随机推荐

  1. MongoDB入门(8)- c#通过操作MongoDB GridFS实现文件的数据库存储

    GridFS介绍 GridFS是MongoDB中的一个内置功能,可以用于存放大量小文件. GridFS GridFS长啥样 /* 1 */ { "_id" : ObjectId(& ...

  2. 快速搭建rabbitmq单节点并配置使用

    安装erlang环境 wget http://erlang.org/download/otp_src_20.3.tar.gz tar xf otp_src_20.3.tar.gz && ...

  3. 【BZOJ】1726 [Usaco2006 Nov]Roadblocks第二短路

    [算法]最短路(spfa) 次短路 [题解] 正反跑两次SPFA,然后枚举每一条边,如果起点到一个端点的最短路+另一个端点到终点的最短路+长度 ≠ 最短路,则和答案比较,保存最小值. #include ...

  4. sass_安装问题(ERROR: Could not find a valid gem 'sass' (>= 0), here is why: Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: cert)

    安装sass前需安装ruby 安装好ruby好打开命令行,输入 gem install sass 出现错误: ERROR: Could not find a valid gem 'sass' (> ...

  5. cuda中的二分查找

    使用背景 通常,在做高性能计算时,我们需要随机的连接某些点.这些点都具有自己的度量值,显然,度量值越大的值随机到的概率就会越大.因此,采用加权值得方法: void getdegreeSum(DG *g ...

  6. 【swupdate文档 二】许可证

    许可证 SWUpdate是免费软件.它的版权属于Stefano Babic和其他许多贡献代码的人(详情请参阅实际源代码和git提交信息). 您可以根据自由软件基金会发布的GNU通用公共许可证第2版的条 ...

  7. Linux 入门记录:三、Linux 文件基本操作管理

    一.复制文件.目录 使用 cp 命令复制文件或目录: $ cp 源文件(夹)目标文件(夹) 常用参数: -r 递归复制整个目录树 -v 显示复制过程的详细信息 二.移动.重命名文件或目录 通过 mv  ...

  8. 移动端测试===Android内存泄露和GC机制(转)

    本文转自:https://www.testwo.com/article/1153 1.前言 Hello,小伙伴们,相信大家在项目测试中都遇到过内存泄露问题,小编也着实爬过很多坑.比如小编所测项目,更换 ...

  9. 使用 ftrace 调试 Linux 内核,第 1 部分【转】

    转自:http://www.ibm.com/developerworks/cn/linux/l-cn-ftrace1/index.html ftrace 是 Linux 内核中提供的一种调试工具.使用 ...

  10. x64dbg

    https://x64dbg.com/ https://github.com/x64dbg/x64dbg https://sourceforge.net/projects/x64dbg/files/s ...