The LoadRunner Blog

Tuesday, November 21, 2006

File Download Test - getting downloaded file size

Giles on the SQAForum has given a code snippet to test for file download.
There are also a series of posts on the Loadrunner list that talks about how Loadrunner behaves in such a test. In short LR does not store a copy of the file , it just receives the packets and the data is then erased. You can however get the property of the files like download size, download time etc. Anyway back to Giles' solution


You simply call the function after the call to download the file.

Calling Action
Code:


Action()
{
web_url("GetPDF",
"URL=http://www.tfl.gov.uk/tfl/pdfdocs/colourmap.pdf",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Mode=HTML",
LAST);


/*Get File Statistics*/
funcFileDownload();


return 0;
}



Called Function:
Code:


float fFileDownloadSize, fFileDownloadTime, fFileDownloadRate;

funcFileDownload()
{
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("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;
}

0 Comments:

Post a Comment

<< Home