Don’t waste your time
Waste time in Load Runner is a time spend on tasks that normal browser user wouldn’t perform like storing test results, performance monitoring, calculations, etc. Wasted time is measured by LR automatically but sometimes it is necessary to use it explicitly through lr_wasted_time() function .
lr_wasted_times() removes time from all open transaction. If you want to make some calculation and don’t count them into overall transaction time then you should use this function.
Small example
-
Action()
-
{
-
merc_timer_handle_t timer;
-
long i;
-
double wastedTime;
-
-
lr_start_transaction("My_Transaction");
-
timer = lr_start_timer();
-
for(i = 0; i < 1000; i++)
-
lr_message("%d\n", i);
-
wastedTime = lr_end_timer(timer);
-
wastedTime*=1000;
-
-
lr_wasted_time(wastedTime);
-
-
lr_end_transaction("My_Transaction", LR_AUTO);
-
lr_message("Wasted %lf milliseconds", wastedTime);
-
return 0;
-
}
On line 7 I’m starting one transaction. On line 8 I’m starting timer and stoping it at line 11. For loop between is used to generate my wasted time. After stopping the time, we need to subtract wasted time from open transaction by calling lr_wasted_time() on line 14. But before that on line 12 we need to change time units. lr_end_timer() returns time in seconds but lr_wasted_time() takes time in milliseconds. Thats why we need to multiply it by 1000. There is one more think. lr_wasted_time() is defined as
-
void lr_wasted_time (long wasteTime);
If you use long type variable to measure wasted time you will always get rounded results (e.g. 1000, 2000, 3000). Instead it is better to use double type variable so at the end the results are more precise.
