Step1:
Create your common method in Loadrunner installation folder, which is usually in ..\Program Files\HP\LoadRunner\include
In calpagesize.h file, here is the source code which simply return the “current page size” you want to measure:
int calpagesize(int Pre_size){
int Temptotalsize=0;
int currentResponseSize = 0;
Temptotalsize = web_get_int_property(HTTP_INFO_TOTAL_RESPONSE_STAT);
return currentResponseSize = Temptotalsize - Pre_size;
}
Step2:apply the calpagesize() method:
Adding #include “calpagesize.h” in your globals.h file
Step3: Adding calculate page size code(in red line) into action:
Take Yahoo home page for example:
Action()
{
int Pre_page_size=0;
int cur_page_size=0;
Pre_page_size=web_get_int_property(HTTP_INFO_TOTAL_RESPONSE_STAT); //get accumulate page size data before sending next request
web_url("www.yahoo.com",
"URL=http://www.yahoo.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
LAST);
if (flag==1){ //flag==1 means trigger the page size func code
cur_page_size = calpagesize(Pre_page_size); //return yahoo home page page size
lr_save_int(atoi(lr_eval_string("{Avg_01_PageSize}"))+cur_page_size, "Avg_01_PageSize"); //save into parameter ” Avg_01_PageSize”
}
}
So normally, we may need to add 4 lines before and after the page you want to calculate the size.
finally, you can calculate the page size in Vuser_end():
lr_message("Avg_01_PageSize = %d", atoi(lr_eval_string("{Avg_01_PageSize}"))/atoi(lr_eval_string("{Iterations}")));
enjoy!
Cheng
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment