Thursday, September 13, 2012

Loadrunner Charting Custom Metrics

In Loadrunner, you can chart your own custom metrics easily by using the function lr_user_data_point.  These could include calls to the server to collect system stats, application metrics based on responses, or anything at all.  The custom metrics are then available in Loadrunner Analysis.  The following provides an example:

Script


double getMyMetric();

Action()
{
double mymetric;
int i;
for (i=0;i<100;i++) {

mymetric = getMyMetric(); 
lr_user_data_point("mymetric", mymetric); 
lr_log_message( "--- Added custom metric value = %f", mymetric );

return 0;
}


double getMyMetric()
{
    int randomInt = (rand() % 100)+1;  // Get a random number 1 - 100
double mymetric = randomInt / 100.0; // Return a double between 0  and 1
return mymetric;
}



Console Output


Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(10): Notify: Data Point "mymetric" value = 0.4800.
--- Added custom metric value = 0.480000
Action.c(10): Notify: Data Point "mymetric" value = 0.7900.
--- Added custom metric value = 0.790000
...


Analysis Output

The custom metric is then available in analysis:


A chart can be generated showing the trend of the custom data points added during the test:




4 comments:

  1. "Well explained! Learn java coaching online
    efficiently with guided lessons, coding exercises, and project work."

    ReplyDelete
  2. iOS app development training focuses on hands-on practice. It includes real-world projects. Structured lessons improve clarity. Coding confidence increases. This ios app development training supports growth. It is dependable.

    ReplyDelete
  3. An ios developer training program focuses on industry-relevant skills. It includes coding and project work. This ios developer training improves employability. It is effective.

    ReplyDelete
  4. "Excellent insights! Learn java coaching online
    from scratch with hands-on coding exercises and real-world projects in our online course. Start your coding journey today."

    ReplyDelete