Test Complete的性能記錄方法

發表于:2008-07-03來源:作者:點擊數: 標簽:性能Complete記錄Testtest
關鍵字:測試 Test Complete主要是一個 功能測試 工具,利用其對GUI控件的識別、動作記錄、回放等腳本技術實現替代部分的人工測試的執行。但是它同時還提供很多機制讓我們在功能測試的同時記錄性能。 MemUsage,CPUUsage 可利用TC(Test Complete)的sys對象
關鍵字:測試
    Test Complete主要是一個功能測試工具,利用其對GUI控件的識別、動作記錄、回放等腳本技術實現替代部分的人工測試的執行。但是它同時還提供很多機制讓我們在功能測試的同時記錄性能。
 
MemUsage,CPUUsage
        可利用TC(Test Complete)的sys對象的屬性獲得關于進程和操作系統的內存、CPU使用情況。
 
        下面腳本記錄當前所有進程和操作系統使用的內存:
   log.Message(VarToStr(Sys.MemUsage)+'%'); 
 
        下面腳本記錄notepad進程的當前內存使用情況:
   Log.Message(VarToStr(Sys.Process('notepad').MemUsage)+'K');
  
 
        通過訪問Sys對象,可以獲取關于CPU的各種信息,例如,CPU處理器、處理器個數、CPU使用率(包括系統的和某個具體進程的)
   //Information on the processor(s) installed on the current computer.
   log.Message( Sys.CPU);
   //Returns the number of processors installed on the current computer.
   log.Message( Sys.CPUCount);
   //Current percentage of CPU time used by the operating system and all running processes.
   log.Message( VarToStr(Sys.CPUUsage)+'%');   
   //the current approximate percentage of the CPU time spent running the process.
   log.Message( VarToStr(Sys.Process('notepad').CPUUsage)+'%'); 
  
        注意:使用TC提供的VarToStr函數把Sys對象的各種屬性變量值轉換成String類型,否則log信息無法顯示值。
 
與AQTime集成
        上面說的方法是TC本身提供的,只能記錄基本的性能參數,例如內存、CPU,TC還提供另外的途徑記錄性能,例如通過與AQTime集成的方式,AQTime是AutomatedQA公司出品的代碼性能測試工具,它能在程序執行過程中記錄每行代碼的執行效率,內存使用情況、代碼覆蓋率等。
 
        與AQTime集成有兩種方式。一種是調用AQTime軟件的方式,另外一種是直接使用AQTime提供的接口對象。
 
        如果采用第一種方式,則首先應該把TC的TestedApps的執行模式改成 Profile 模式,可在TestedApps editor中設置,也可在腳本中設置,例如:
 
var
 MyApp : OleVariant;
begin
 // Obtains the tested application
 MyApp := TestedApps.MyTestedApp;
 
 // Specifies the run mode parameters
 MyApp.Params.ProfileParams.AQtimeVersion := 5;
 MyApp.Params.ProfileParams.ProfilerName := 'Coverage Profiler';
 MyApp.Params.ProfileParams.RunMode := 'Normal';
 MyApp.Params.ProfileParams.UseProject := False;
 
 // Activates the Profile run mode
 MyApp.Params.ProfileParams.Activate;
 ...
end;

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97