未来已来

hp winrunner 百问 三

上一篇 / 下一篇  2008-10-16 22:29:04 / 个人分类:自动化测试

winRunner api 调用,例子中实现如何获得功能执行时间

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");

#-----------------------------------------------------------------------------------------------------------------
# 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);



TAG: 自动化测试

 

评分:0

我来说两句

Open Toolbar