Example: Sub-transactions

This example shows how the durations of nested sub-transactions are reported.

Several sub-transactions are started with start_sub_transaction and ended with end_sub_transaction. These sub-transactions are nested and overlapped in various ways. The output below the example shows that the duration of each sub-transaction is the time between the start and end of that individual sub-transaction, entirely independent of what other sub-transactions are active at the same time.

Dim i as Integer
Dim baseIter as Integer
baseIt(er = 1000)
' Start Parent
lr.start_transaction "Master"

' Start first sub transaction
lr.start_sub_transaction "FirstT", "Master" 

' Start nested child of first sub transaction
lr.start_sub_transaction "FirstT_Child1", "FirstT" 

' Pause between scripts
lr.think_time 1.5

' Start a sub transaction while FirstT_Child1 is still active.
lr.start_sub_transaction "FirstT_OverLap_Child1And2", "FirstT" 

' Create some elapsed time
lr.think_time 0.5

' End FirstT_Child1. 
' FirstT_OverLap_Child1And2 is still active
lr.end_sub_transaction "FirstT_Child1",lr.AUTO 

' Start second nested child
lr.start_sub_transaction "FirstT_Child2", "FirstT" 

' Pause between scripts
lr.think_time 1

' End the overlapping sub transaction
lr.end_sub_transaction "FirstT_OverLap_Child1And2",lr.AUTO 

' Pause between scripts
lr.think_time 1.75
lr.end_sub_transaction "FirstT_Child2",lr.AUTO 
lr.end_sub_transaction "FirstT",lr.AUTO 

' Start a second sub transaction
lr.start_sub_transaction "SecondT", "Master"     

' Pause between scripts
lr.think_time 2
lr.end_sub_transaction "SecondT",lr.AUTO 
lr.end_transaction "Master", lr.AUTO 
Example:  Output:
Notify: Transaction Master started.
Notify: Transaction FirstT started.
Notify: Transaction FirstT_Child1 started.
lr_think_time: 1.50 seconds.
Notify: Transaction FirstT_OverLap_Child1And2 started.
lr_think_time: 0.50 seconds.
Notify: Transaction FirstT_Child1 ended with Pass status (Duration: 2.0029 Think Time: 2.0029).
Notify: Transaction FirstT_Child2 started.
lr_think_time: 1.00 seconds.
Notify: Transaction FirstT_OverLap_Child1And2 ended with Pass status (Duration: 1.5022 Think Time: 1.5022).
lr_think_time: 1.75 seconds.
Notify: Transaction FirstT_Child2 ended with Pass status (Duration: 2.7540 Think Time: 2.7540).
Notify: Transaction FirstT ended with Pass status (Duration: 4.7669 Think Time: 4.7568).
Notify: Transaction SecondT started.
lr_think_time: 2.00 seconds.
Notify: Transaction SecondT ended with Pass status (Duration: 2.0029 Think Time: 2.0029).
Notify: Transaction Master ended with Pass status (Duration: 6.7797 Think Time: 6.7597).