saving duration as a parameter in a vugen script (298 Views)
Reply
Advisor
Shenay
Posts: 22
Registered: ‎01-26-2013
Message 1 of 6 (298 Views)
Accepted Solution

saving duration as a parameter in a vugen script

Hi All,

I want to save the duration of a transaction as a parameter (time which takes to script runs and completes) and according to this parameter I want to define if transaction fails. for example if it takes more than 5 seconds for transaction to be completed I want it  to finish with lr_end_transaction ("transaction_name", lr_fail)

is there a way to do this?

thanks

Frequent Advisor
espavankumar
Posts: 33
Registered: ‎08-17-2011
Message 2 of 6 (283 Views)

Re: saving duration as a parameter in a vugen script

you could do this.

 

 

   double wasteTime, actualElapsedTime;
    merc_timer_handle_t MasterT;

 

lr_start_transaction("myTransaction1");
// Examine the total elapsed time of the action
    MasterT = lr_start_timer();

.....

..... your w_s_d or any other code

 

actualElapsedTime = lr_end_timer(MasterT);

 

if (actualElapsedTime>=something)

          lr_end_transaction("myTransaction1",LR_PASS);

else

 

          lr_end_transaction("myTransaction1",LR_FAIL);

 

 

Pavankumar
Advisor
Shenay
Posts: 22
Registered: ‎01-26-2013
Message 3 of 6 (269 Views)

Re: saving duration as a parameter in a vugen script

Hi PavanKumar,

 

thanks for reply,

I added the codes to the script but it did not work.

in this script I want to ping an IP and if I can not ping it I want the script fails.

the script is below. although I can not ping the IP is sasys transaction pass.

 

Action()
{
    double wasteTime, actualElapsedTime;

  
merc_timer_handle_t MasterT2; 

 

    lr_start_transaction("Ping_Tempo");
    MasterT2 = lr_start_timer();
 
    system("ping X.X.X.X");
    if (actualElapsedTime<=5)

          lr_end_transaction("Ping_Tempo",LR_PASS);

else

 

          lr_end_transaction("Ping_Tempo",LR_FAIL);


    return 0;

Frequent Advisor
espavankumar
Posts: 33
Registered: ‎08-17-2011
Message 4 of 6 (254 Views)

Re: saving duration as a parameter in a vugen script

your code wont work because you have not ended the timer. lr_end_timer.

Pavankumar
Advisor
Shenay
Posts: 22
Registered: ‎01-26-2013
Message 5 of 6 (241 Views)

Re: saving duration as a parameter in a vugen script

Thanks very much it worked :)

Frequent Advisor
espavankumar
Posts: 33
Registered: ‎08-17-2011
Message 6 of 6 (230 Views)

Re: saving duration as a parameter in a vugen script

cool. can you mark my answer as solved?

Pavankumar
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.