Creating Custom Metric Graphs with HP Loadrunner

perfcenter-userdatapoints

This post will describe how to create your own custom metric graphs in HP Loadrunner. Using the Analysis tool you can view the standard metrics of a Load Test. But you can also use the VuGen scripts to report your own numbers as ‘User Data Points’ and feed them into the Analysis component.

Let’s assume you would like to report data contained within HTTP responses. E.g. Reporting the number of offered products displayed on a search result page.

This is how you woud go about achieving this:

int count;
// retrieve the number of available products displayed on the result page <a href="http://paydaylonesbroker.com/">fast and easy payday loans</a>:
web_reg_find("Text=product_id=", "SaveCount=productsCount",LAST);

web_url("search-products",
"URL=http://shop.yourdomain.com/search.html?product=portable",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t6.inf",
"Mode=HTML",
LAST);

count = atoi(lr_eval_string("{productsCount}"));
// report the metric as user data points:
lr_user_data_point("Number of products", (double) count);

This is how User Data Points are made available as a live graph on the Performance Center user inteface:

User Data Points displayed during the test execution on the Performance Center UI

… and this is how it is rendered in the Analysis tool:

User Data Points displayed in Analysis

This is an extremely powerful and useful tool when used in the right circumstances.

Leave a Reply

Your email address will not be published. Required fields are marked *