Choosing Ajax(click and scripts) protocol;
pre-condition: set your log level as "send message only when an error occurs"
Within globe()
set one flag to trigger the page size func code on demand:
int flag=0;
Within vuser_init()Action, you can initial such parameter as:
lr_save_int(0, "accu_google_frontpage_PageSize");
Within Action() i take google landing page as a example:
int ThisTimeHttpResponseSize=0;
char *message;
int i=0;
int loops=2;
lr_save_int(loops,"loops_goo");
while(i小于loops){//if there is some loops here
message=(char *)malloc(140*sizeof(char));
memset(message, 0, sizeof(char));
web_browser("www.google.com",
DESCRIPTION,
ACTION,
"Navigate=http://www.google.com/",
LAST);
i++;
if (flag==1) {//enable pagesize func, if flag==1;
lr_set_debug_message(LR_MSG_CLASS_JIT_LOG_ON_ERROR, LR_SWITCH_OFF);
//web_get_int_property Returns the accumulated size, including header and body,
ThisTimeHttpResponseSize = web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);
strcat(message, "PageSize_of_google_frontpage_");
strcat(message, lr_eval_string("{Iteration}"));
strcat(message, " = %d");
lr_message(message, ThisTimeHttpResponseSize);
lr_set_debug_message(LR_MSG_CLASS_JIT_LOG_ON_ERROR, LR_SWITCH_ON);
//multiple iteration accumulated
lr_save_int(atoi(lr_eval_string("{accu_google_frontpage_PageSize}"))+ThisTimeHttpResponseSize, "accu_google_frontpage_PageSize");
}
free(message);
}
within end() action, calculate the average number of each page size:
if (flag==1) {
lr_save_int(atoi(lr_eval_string("{Iteration}")), "Iterations");
lr_set_debug_message(LR_MSG_CLASS_JIT_LOG_ON_ERROR, LR_SWITCH_OFF);
lr_message("Iterations=%s",lr_eval_string("{Iterations}"));
lr_message("Avg_google_frontpage_PageSize = %d", atoi(lr_eval_string("{accu_google_frontpage_PageSize}"))/(atoi(lr_eval_string("{loops_goo}"))*atoi(lr_eval_string("{Iterations}"))));
lr_set_debug_message(LR_MSG_CLASS_JIT_LOG_ON_ERROR, LR_SWITCH_ON);
}
So you will get each page size freely now!
Thanks my friend Jeff,Alfred and Calvin previous sample code and ideas!
No comments:
Post a Comment