51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1908|回复: 0
打印 上一主题 下一主题

WinRunner:Transaction Time Reporting to 1000th of a Second

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2006-10-30 14:31:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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.
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-15 14:04 , Processed in 0.062474 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表