Friday, January 23, 2015

How to calculate doc download time in LoadRunner

Lets says that we have a document in one of the pages that we record in VuGen and we have to capture the time it takes to download only that file, then Use the below steps after the step which downloads the file.
Note that the RecContentType=application/pdf for the step

web_url("BCAction.do",
        "URL={url}//BCAction.do?choice=display&ctno=1234567890",
        "Resource=1",
        "RecContentType=application/pdf",
        "Referer=",
        "Snapshot=t24.inf",
        LAST);

 time = web_get_int_property(HTTP_INFO_DOWNLOAD_TIME);        
 lr_output_message("The time in ms to download CSS PDF is: %d",time);


Some more information about Web_get_int_property
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(Java scripts).

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

This function is supported for all Web scripts, and for WAP scripts running in HTTP mode only. It is not supported for WAP scripts running in Wireless Session Protocol (WSP) replay mode