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.pswp.cn/news/376007.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/376007.shtml
英文地址,請注明出處:http://en.pswp.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…