saving duration as a parameter in a vugen script (255 Views)
Reply
Advisor
Shenay
Posts: 21
Registered: ‎01-26-2013
Message 1 of 6 (255 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

Please use plain text.
Advisor
espavankumar
Posts: 19
Registered: ‎08-17-2011
Message 2 of 6 (240 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
Please use plain text.
Advisor
Shenay
Posts: 21
Registered: ‎01-26-2013
Message 3 of 6 (226 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;

Please use plain text.
Advisor
espavankumar
Posts: 19
Registered: ‎08-17-2011
Message 4 of 6 (211 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
Please use plain text.
Advisor
Shenay
Posts: 21
Registered: ‎01-26-2013
Message 5 of 6 (198 Views)

Re: saving duration as a parameter in a vugen script

Thanks very much it worked :)

Please use plain text.
Advisor
espavankumar
Posts: 19
Registered: ‎08-17-2011
Message 6 of 6 (187 Views)

Re: saving duration as a parameter in a vugen script

cool. can you mark my answer as solved?

Pavankumar
Please use plain text.
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