LoadRunner中如何验证下载的文件大小、统计下载时间、度量下载速度?
2010-02-02 17:41
567 查看
LoadRunner中的web_get_in_property函数可用于返回上一个HTTP请求的相关信息,包括HTTP请求返回码、下载大小、下载时间等:
The web_get_int_property function returns specific information about the previous HTTP request.
The meaning of the return value depends on the HttpInfoType argument. HttpInfoType can be any of the following options. The first constant in each pair (HTTP_*) is for C, the second (object.HTTP_*) is for object oriented languages.
HTTP_INFO_RETURN_CODE or object.HTTP_INFO_RETURN_CODE
The return code in HTTP response header.
HTTP_INFO_DOWNLOAD_SIZE or object.HTTP_INFO_DOWNLOAD_SIZE
The size (in bytes) of the last download, including the header, body, and communications overhead (for example, NTLM negotiation).
HTTP_INFO_DOWNLOAD_TIME or object.HTTP_INFO_DOWNLOAD_TIME
The time in (milliseconds) of the last download.
HTTP_INFO_TOTAL_REQUEST_STAT or object.HTTP_INFO_TOTAL_REQUEST_STAT
Returns the accumulated size of all headers and bodies since the first time web_get_int_property was issued with HTTP_INFO_TOTAL_REQUEST_STAT.
HTTP_INFO_TOTAL_RESPONSE_STAT or object.HTTP_INFO_TOTAL_RESPONSE_STAT
Returns the accumulated size, including header and body, of all responses since the first time web_get_int_property was issued with HTTP_INFO_TOTAL_RESPONSE_STAT
下面脚本发送HTTP请求下载一个PNG图片,然后用web_get_int_property取得这次请求相关的信息:
Action()
{
int returnCode;
float fFileDownloadSize, fFileDownloadTime, fFileDownloadRate;
web_url("Image1",
"URL=http://localhost/welcome.png",
"Resource=1",
LAST);
returnCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
fFileDownloadSize = (web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE)/1024.); //in kilobytes
fFileDownloadTime = (web_get_int_property(HTTP_INFO_DOWNLOAD_TIME)/1000.); //in seconds
fFileDownloadRate = fFileDownloadSize/fFileDownloadTime; //in KB/s
lr_output_message("Return Code = %d",returnCode);
lr_output_message("Size of download was %.0f kilobytes; Time of download was %.3f seconds", fFileDownloadSize, fFileDownloadTime);
lr_output_message("Rate of download was %.2f KB/sec", fFileDownloadRate);
return 0;
}
参考:http://www.loadrunnertnt.com/how-tos/how-to-verify-file-downloaded/
The web_get_int_property function returns specific information about the previous HTTP request.
The meaning of the return value depends on the HttpInfoType argument. HttpInfoType can be any of the following options. The first constant in each pair (HTTP_*) is for C, the second (object.HTTP_*) is for object oriented languages.
HTTP_INFO_RETURN_CODE or object.HTTP_INFO_RETURN_CODE
The return code in HTTP response header.
HTTP_INFO_DOWNLOAD_SIZE or object.HTTP_INFO_DOWNLOAD_SIZE
The size (in bytes) of the last download, including the header, body, and communications overhead (for example, NTLM negotiation).
HTTP_INFO_DOWNLOAD_TIME or object.HTTP_INFO_DOWNLOAD_TIME
The time in (milliseconds) of the last download.
HTTP_INFO_TOTAL_REQUEST_STAT or object.HTTP_INFO_TOTAL_REQUEST_STAT
Returns the accumulated size of all headers and bodies since the first time web_get_int_property was issued with HTTP_INFO_TOTAL_REQUEST_STAT.
HTTP_INFO_TOTAL_RESPONSE_STAT or object.HTTP_INFO_TOTAL_RESPONSE_STAT
Returns the accumulated size, including header and body, of all responses since the first time web_get_int_property was issued with HTTP_INFO_TOTAL_RESPONSE_STAT
下面脚本发送HTTP请求下载一个PNG图片,然后用web_get_int_property取得这次请求相关的信息:
Action()
{
int returnCode;
float fFileDownloadSize, fFileDownloadTime, fFileDownloadRate;
web_url("Image1",
"URL=http://localhost/welcome.png",
"Resource=1",
LAST);
returnCode = web_get_int_property(HTTP_INFO_RETURN_CODE);
fFileDownloadSize = (web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE)/1024.); //in kilobytes
fFileDownloadTime = (web_get_int_property(HTTP_INFO_DOWNLOAD_TIME)/1000.); //in seconds
fFileDownloadRate = fFileDownloadSize/fFileDownloadTime; //in KB/s
lr_output_message("Return Code = %d",returnCode);
lr_output_message("Size of download was %.0f kilobytes; Time of download was %.3f seconds", fFileDownloadSize, fFileDownloadTime);
lr_output_message("Rate of download was %.2f KB/sec", fFileDownloadRate);
return 0;
}
参考:http://www.loadrunnertnt.com/how-tos/how-to-verify-file-downloaded/
相关文章推荐
- LoadRunner中如何验证下载的文件大小、统计下载时间、度量下载速度
- LoadRunner中如何验证下载的文件大小、统计下载时间、度量下载速度?
- LoadRunner中如何验证下载的文件大小、统计下载时间、度量下载速度?
- LoadRunner中如何验证下载的文件大小、统计下载时间、度量下载速度?
- MFC 的几个常用函数,用来计算文件大小,下载速度,转换时间的
- MFC 的几个常用函数,用来计算文件大小,下载速度,转换时间的
- MFC 的几个常用函数,用来计算文件大小,下载速度,转换时间的
- 如何修改WAMP数据库上传文件的大小及上传时间限制
- 如何利用代码从网站上获取一个文件的大小,并且下载时不出现保存提示框
- Android APK文件下载 并自动安装 显示文件下载进度,速度,以及花费时间
- linux下统计当前文件夹中文件的数目以及如何查看文件夹的大小
- awk算术运算一例:统计hdfs上某段时间内的文件大小
- awk算术运算一例:统计hdfs上某段时间内的文件大小
- html5 如何实现客户端验证上传文件的大小
- 上传速度 、已用时间、预计剩余时间 上传资源时 上传文件大小,已上传大小 进度%
- 设置IIS6.0的上传文件和下载附件的大小限制(验证过确实有效)
- 如何实现文件下载的次数统计?
- 如何让LoadRunner可以下载文件并保…
- 使用URL类下载网页文件,并网页文件统计大小