top of page

How To Check The Duration Of Transaction In The Middle Of Execution In Vugen?


How To Check The Duration Of Transaction In The Middle Of Execution In Vugen?

By Sam Z // Tuesday, October 22, 2013

You can check the duration of transaction in middle of the execution in vugen by using the following method.

For example, in the middle of the execution the user wants to check the response time of a transaction. If the user found that the response time is more than 10 seconds the user wants to stop the transaction else continue with the execution of the script.

This can be achieved using lr_stop_transaction and lr_resume transaction.

lr_stop_transaction function will not end a transaction but it stops the timing of a transaction. It is useful for validating purposes. You can include a conditional statement after calling the stop function as shown in the below example.

Example:

  • Start transaction.

  • Google.com request Sent.

  • Stop transaction(lr_stop_transaction).

  • Take the duration of the transaction.

  • If it is more than 10 seconds stop the transaction.

  • Else.

  • Continue with the transaction(lr_resume_transaction).

Script Example:

Action()

{

double dur;

lr_start_transaction("GoogleHomePage");

web_url("GoogleHomePage",

"URL=http://www.google.com/",

"Mode=HTML",

LAST );

dur = lr_get_transaction_duration("GoogleHomePage");

lr_stop_transaction("GoogleHomePage");

if (dur>10)

{

lr_log_message("Response time of this transaction is", dur);

lr_end_transaction("GoogleHomePage", LR_AUTO);

}

else

{

lr_resume_transaction("GoogleHomePage");

lr_log_message("Response time of this transaction is %f", dur);

lr_end_transaction("GoogleHomePage", LR_AUTO);

}

return 0;

}


bottom of page