51Testing软件测试论坛

标题: WinRunner:Transaction Time Reporting to 1000th of a Second [打印本页]

作者: pcl2004_27    时间: 2006-10-30 14:31
标题: WinRunner:Transaction Time Reporting to 1000th of a Second
Description

      Below is a function which helps automate reporting of transaction times to the 1000th of a second.


Solution

      The function detailed below works in conjunction with the Win32API function GetTickCount to report transaction times to the 1000th of a second. The time lapse of each timed transaction can be automatically posted to the test's results report or alternatively to a text file.

Here is how it is done.
load_dll ("C:\\WINNT\\SYSTEM32\\kernel32.dll");
extern int GetTickCount();
<code code code>
start=GetTickCount();
<transaction to be timed code goes here>
end=GetTickCount();
# Note posting to a file
post_tick_count_time_lapse(start,end,"Transaction Title","C:\\temp.txt");

That's it.

Posting to the results report would simply be post_tick_count_time_lapse(start,end,"Transaction Title");

# FUNCTION CODE BELOW
public function post_tick_count_time_lapse (in starttime, in endtime, in transtitle, in filename)
{
# Declare variables
auto timelapse;
# Validate parameters
if (nargs() != 3 && nargs() != 4)
{
tl_step ("get_tick_count_time_lapse", FAIL, "Only 3 or 4 parameters are allowed.");
return(E_ILLEGAL_NUM_OF_PARAMS);
}
# Determine how long the transaction took and round
timelapse = int((endtime - starttime) + .5)/1000;
# Post timelapse
if (nargs() == 3) # Was no ouput file specified
report_msg (transtitle & " : " & timelapse & " seconds"); # Send output to the test results
else # There was an ouput file specified
{
print (transtitle & " : " & timelapse & " seconds |" & get_time()) >> filename; # Append output to specified file
# Note "|" is a file delimiter above
close(filename);
}
return(E_OK);
}

Hope you can find it of some use.




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2