日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

lr_start_timer,lr_get_transaction_duration,lr_get_transaction_wasted_time函数使用总结

發(fā)布時(shí)間:2023/12/1 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 lr_start_timer,lr_get_transaction_duration,lr_get_transaction_wasted_time函数使用总结 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

lr_start_timer:

函數(shù)的功能:

為了計(jì)算時(shí)間更加精確,可以用這個(gè)函數(shù)去掉LR自身的檢查點(diǎn)所浪費(fèi)的時(shí)間。如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:返回事件執(zhí)行到此處所用的時(shí)間

C 語(yǔ)言:double lr_get_transaction_duration(const char *transaction);Example:Action(){double Connect_trans_time; // 接收函數(shù)返回值double Move_trans_time;lr_start_transaction("Connect_trans");lr_create_socket("socket0","TCP","RemoteHost = localhost:1111",LrsLastArg); // IP和端口僅供參考//......(others)// 調(diào)用 lr_get_transaction_duration() 函數(shù) 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 事件執(zhí)行到此處所用時(shí)間 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根據(jù)業(yè)務(wù)操作分離出腳本中的兩個(gè)事件,Connect(連接DB)操作和Move(拖屏)操作,Contro中運(yùn)行結(jié)果顯示“拖屏”消耗時(shí)間遠(yuǎn)大于“連接”消耗時(shí)間,這同程序設(shè)計(jì)與實(shí)現(xiàn)的實(shí)際情況不符。所以調(diào)用了【lr_get_transaction_duration();】函數(shù)來(lái)驗(yàn)證事件的運(yùn)行時(shí)間,進(jìn)一步分析性能問(wèn)題原因所在。驗(yàn)證結(jié)果已證明拖屏操作消耗時(shí)間的確小于連接操作消耗時(shí)間。


?

lr_get_transaction_wasted_time:函數(shù)用于返回指定事物當(dāng)前的損耗時(shí)間(wasted time)。

函數(shù)統(tǒng)計(jì)的是事物開(kāi)始到此函數(shù)位置,lr自身的浪費(fèi)時(shí)間(如:執(zhí)行關(guān)聯(lián)、檢查點(diǎn)等函數(shù)的時(shí)間)。
?
損耗時(shí)間通常是指腳本消耗在為了支持測(cè)試分析而做的操作時(shí)間。這些操作不會(huì)被實(shí)際用戶所執(zhí)行。
?
例如一些循環(huán)賦值操作或插入檢查點(diǎn)操作。消耗的時(shí)間有l(wèi)r_wasted_time函數(shù)在

?
lr_get_transaction_wasted_time函數(shù)之前移除了,移除后才得到對(duì)應(yīng)的結(jié)果。

函數(shù)語(yǔ)法結(jié)果

double lr_get_transaction_wasted_time (const char * transaction);

參數(shù) transaction 為事物名稱

?
使用lr_get_transaction_wansted_time
函數(shù)必須注意,

一它只能對(duì)當(dāng)前運(yùn)行狀態(tài)的事物才能返回大于等于0的結(jié)果,否則返回小于0的結(jié)果。

二是他使用之前應(yīng)調(diào)用lr_wansted_time 函數(shù)移除過(guò)損耗時(shí)間
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時(shí)間為:%f",time_elapsed);lr_output_message("事務(wù)當(dāng)前的損耗時(shí)間為:%f",lr_get_transaction_wasted_time("登陸")); //先算出從事務(wù)開(kāi)始到現(xiàn)在lr自身的浪費(fèi)時(shí)間。因?yàn)闊o(wú)損耗,所以,lr_get_transaction_wasted_time= 0s 。//使用lr_wasted_time()函數(shù)為事物添加浪費(fèi)時(shí)間lr_wasted_time(time_elapsed*1000); //Wasted Time=lr自身的浪費(fèi)時(shí)間(0s)+第三方時(shí)間的開(kāi)銷(time_elapsed*1000s))lr_output_message("find時(shí)間為:%f,事務(wù)當(dāng)前的損耗時(shí)間為:%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; }結(jié)果: 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函數(shù)用于返回指定事物當(dāng)前的損耗時(shí)間(wasted time)。 ? ? 損耗時(shí)間通常是指腳本消耗在為了支持測(cè)試分析而做的操作時(shí)間。這些操作不會(huì)被實(shí)際用戶所執(zhí)行。 ? ? 例如一些循環(huán)賦值操作或插入檢查點(diǎn)操作。消耗的時(shí)間有l(wèi)r_wasted_time函數(shù)在
? lr_get_transaction_wasted_time函數(shù)之前移除了,移除后才得到對(duì)應(yīng)的結(jié)果。
? 函數(shù)語(yǔ)法結(jié)果
? double lr_get_transaction_wasted_time (const char * transaction);
? 參數(shù) transaction 為事物名稱
? 使用lr_get_transaction_wansted_time 函數(shù)必須注意,一它只能對(duì)當(dāng)前運(yùn)行狀態(tài)的事物才能返回大于等于0的結(jié)果,否則返回小于0的結(jié)果。二是他使用之前應(yīng)調(diào)用lr_wansted_time 函數(shù)移除過(guò)損耗時(shí)間 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 StatusTransaction Father Tree pathScenario Elapsed TimeTransaction Response TimeTransaction 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

?
?

轉(zhuǎn)載于:https://www.cnblogs.com/qmfsun/p/4481395.html

總結(jié)

以上是生活随笔為你收集整理的lr_start_timer,lr_get_transaction_duration,lr_get_transaction_wasted_time函数使用总结的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。