Http://wenku.baidu.com/view/8ba2121ec281e53a5802fff2.html transaction response time includes: function itself, think time, wasted time (execution of correlation, checkpoint, etc.), response time
Wastetime ()
{
int I, baseiter = 1000;
Char dude[1000];
Double Wastetime, Actualelapsedtime;
merc_timer_handle_t Mastert, timer;
Examine the total elapsed time of the action
Mastert = Lr_start_timer ();
Start Transaction
Lr_start_transaction ("Demo");
Create some elapsed time for the transaction
for (i=0; i< (Ten * baseiter); ++i)
sprintf (Dude,
"This is the-the-elapsed time artificially =%d", i);
Add some think time
Lr_think_time (0.5);
Create some wasted time and record it with timer
Timer = Lr_start_timer();
for (i=0; i< (5 * baseiter); ++i)
sprintf (Dude,
"This is the the-the-waste time in a script =%d", i);
Wastetime = Lr_end_timer(timer);
Lr_output_message ("User created waste time =%lf", wastetime);
Lr_output_message ("before lr_waste_time:duration =%lf-waste =%lf",
Lr_get_transaction_duration ("Demo"),
Lr_get_transaction_wasted_time ("Demo")); ---->duration = 0.609375-waste = 0.000000
/* Convert Timer in seconds to wasted time in milliseconds
and add to internally generated waste time */
Wastetime *= 1000;
Lr_wasted_time (Wastetime);
Lr_output_message ("after lr_waste_time:duration =%lf-waste =%lf",
Lr_get_transaction_duration ("Demo"),
Lr_get_transaction_wasted_time ("Demo"));----> Duration = 0.625000-waste = 0.031000
Lr_output_message ("Think time =%lf",
Lr_get_transaction_think_time ("Demo"));
Lr_end_transaction ("Demo", Lr_auto);
Actualelapsedtime = Lr_end_timer (Mastert);
Lr_output_message ("Total Elapsed time for Action =%lf",
Actualelapsedtime);
return 0;
}
VUser Output log file
Note There is no difference between the transaction duration before
WASTETIME.C: User created waste time = 0.031250
WASTETIME.C (+): before lr_waste_time:duration = 0.609375-waste = 0.000000
WASTETIME.C (+): after lr_waste_time:duration = 0.625000-waste = 0.031000
WASTETIME.C (): Think time = 0.500000
WASTETIME.C: Notify:transaction Demo ended with Pass status (duration:0.6406 Think time:0.5000 wasted time:0.0310) .
WASTETIME.C (): Total Elapsed time for Action = 0.640625
Lr_start_timer (s), Lr_end_timer (unit s), Lr_wasted_time (the function's formal parameter is in milliseconds, so the time required to pass the timer is 1000