博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LoadRunner中如何验证下载的文件大小、统计下载时间、度量下载速度?
阅读量:4199 次
发布时间:2019-05-26

本文共 2035 字,大约阅读时间需要 6 分钟。

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://hznli.baihongyu.com/

你可能感兴趣的文章
yii2 php namespace 引入第三方非namespace库文件时候,报错:Class not found 的解决
查看>>
softlayer 端口开放
查看>>
操作1:mongodb安装
查看>>
操作2:mongodb使用语法
查看>>
如何给分类增加一个属性(后台)
查看>>
linux设置环境变量 临时设置 和 永久设置
查看>>
检查网站在世界各地的打开速度
查看>>
jquery 向上(顶部),向下(底部)滑动
查看>>
seo
查看>>
10个出色的NoSQL数据库
查看>>
MySQL: InnoDB 还是 MyISAM?
查看>>
MySQL性能优化的最佳20+条经验
查看>>
SQL语言的组成部分 ddl dcl dml
查看>>
mysql数据库从库同步延迟的问题
查看>>
1.mysql数据库主从复制部署笔记
查看>>
mysql数据库主从同步的问题解决方法
查看>>
mysql 配置 - on xFanxcy.com
查看>>
MySQL数据库高并发优化配置
查看>>
mysql一: 索引优化
查看>>
测试人员,今天再不懂BDD就晚了!
查看>>