JavaScript Functions > Alphabetical Listing of Utility Functions (lr) > lr.resumeTransaction


Resumes reporting transaction data within a script.

Example: Transactions Transaction Functions


lr.resumeTransaction( transactionName );

This function is retained for backward compatibility. For more general ways of reporting partial transaction durations, see lr.setTransaction.

The lr.resumeTransaction function resumes the reporting of transaction data within the script that was suspended by lr.stopTransaction. After a call to lr.stopTransaction, statistics returned by the "get" Transaction Functions reflect only the data up to that call, until this function is called.

Data collection, however, is not interrupted. After the call to lr.resumeTransaction, the "get" functions return all data since the start of the transaction. Furthermore, the final results when the test is analyzed will reflect the total values, including the periods in between the transaction stop and resume.

If lr.resumeTransaction is not called, the "get" functions and the final results reflect only the duration from the transaction start to the lr.stopTransaction call. Thus, lr.stopTransaction and lr.resumeTransaction can be used conditionally to collect information either about an entire transaction, or only the beginning. To accomplish this, call lr.resumeTransaction only if your condition is met.

Note: When data is collected this way, the data in analysis will reflect both the tests where the condition for lr.resumeTransaction is met, and the tests where it is not.

If the section you may wish to exclude ends before the end of the transaction, this technique does not apply. If you need to differentiate between occurrences where the lr.resumeTransaction condition is met and those where it is not in the analysis data, this technique does not apply.

For other ways of recording durations conditionally, see lr.setTransaction.

Return Values

Not applicable


You cannot use standard parameterization for any arguments in this function.


function Action(){
    var i;
    var iteration = 100;
    var aStr =[];
 /* Do part of business process. Represented
        here by loop to ensure that some 
        time passes. */
 for (i=0; i < iteration; ++i) {
    /* Output the duration to this point (0.343750 seconds)
        with transaction active. */
    lr.outputMessage("First time = "+lr.getTransactionDuration("Stop&Start"));
    // Stop the transaction
    /* Output the duration to this point (0.359375 seconds)
        with transaction stopped. */

    lr.outputMessage("Immediately after stop = "+lr.getTransactionDuration("Stop&Start"));

    // Ensure that some time passes
    for (i=0; i < iteration; ++i) {

    /* Output the duration to this point (0.359375 seconds)
        with transaction still stopped but 
        more time passed. Note that time is the same.
        The time spent in the loop while the transaction
        was stopped is not reported. */
    lr.outputMessage("After stop and loop = "+lr.getTransactionDuration("Stop&Start"));

    // Resume the transaction
    /* Note that with the transaction resumed,
        all the time passed since the start is 
        reported (0.781250 seconds), including the time spent 
        in the loop while the transaction was stopped. */
    lr.outputMessage("After resume time = "+lr.getTransactionDuration("Stop&Start"));

    // Add time to duration
    for (i=0; i < iteration; ++i) {

    /* Total time reported (1.140625 seconds) */
    lr.outputMessage("After resume and loop = " + lr.getTransactionDuration("Stop&Start"));    

    // End transaction
    return 0;