lr.start_sub_transaction
Starts a sub-transaction specified by its parent's name.
JavaScript
function lr.start_sub_transaction( sub_transaction, parent_transaction )
VBScript
Function lr.start_sub_transaction( sub_transaction, parent_transaction )
| Transaction Functions |
Arguments
| Name | Comments |
|---|---|
| sub_transaction | The name of the sub-transaction |
| parent_transaction | The name of the parent transaction in which the sub-transaction is nested. |
The lr.start_sub_transaction function marks the beginning of a sub-transaction. To mark the end of the sub-transaction, use lr.end_sub_transaction. You insert these functions immediately before and after the sub-transaction actions.
Sub-transactions are used for isolating parts of a business process. For example, a sub-transaction "electrical_purchases" may be nested within the larger transaction "purchases." The transaction "purchases" is the parent transaction and "electrical_purchases" the sub-transaction.
Multiple sub-transactions can be nested within a parent transaction. A sub-transaction may also be a parent to a smaller sub–transaction.
The duration of a transaction or sub-transaction is the sum of the durations of all steps between its start and end, including the steps that are included in sub-transactions.
Each lr.start_sub_transaction statement must be matched with an lr.end_sub_transaction statement within the script or it will be interpreted as an illegal command.
Note: For information on allowed characters and maximum length for transaction names, see Transaction guidelines in the Virtual User Generator Help Center.
Return Values
On success, returns 0. Returns -1 if the transaction name is illegal or if there is no prior call to lr.start_transaction with a transaction of the same name.
Parameterization
All string input arguments can be passed using standard parameterization.VBScript Example
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).

