Share this page

# lr.wastedTime

Sets the wasted time for all open transactions.

Transaction Functions

## Syntax

    lr.wastedTime( wasteTime );

## Arguments

Argument | Comments
--- | ---
wasteTime | The time in milliseconds to be set for all open transactions.

lr.wastedTime allows you to subtract the time wasted on incidental or secondary actions from all open transactions.

For more information, see Wasted Time.

## Return Values

Not applicable

## Parameterization

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

## Example

Copy code

    function Action(){
        var i, baseIter = 1000;
        var dude;
        var wasteTime, actualElapsedTime;
        var MasterT, timer;

        // Examine the total elapsed time of the action
        MasterT = lr.startTimer();

        //Start transaction
        lr.startTransaction("Demo");

        // Create some elapsed time for the transaction
        for (i=0; i< (10 * baseIter); ++i)
                dude = "This is the way we create elapsed time artificially = "+ i;

        // Add some think time
        lr.thinkTime(0.5);

        // Create some wasted time and record it with timer
        timer = lr.startTimer();

        for (i=0; i< (5 * baseIter); ++i)
                dude = "This is the way we waste time in a script = " + i;

        wasteTime = lr.endTimer(timer);
        lr.outputMessage("User created waste time = " + wasteTime);
        lr.outputMessage("Before lr_waste_time: Duration = "
           +lr.getTransactionDuration("Demo")+" - Waste = "
           + lr.getTransactionWastedTime("Demo")
    );

        /* Convert Timer in seconds to wasted time in milliseconds
           and add to internally generated waste time */
        wasteTime *= 1000;
        lr.wastedTime(wasteTime);
        lr.outputMessage("After lr_waste_time: Duration = "
           +lr.getTransactionDuration("Demo"),+" - Waste = "
           + lr.getTransactionWastedTime("Demo"));

        lr.outputMessage("Think time = " + lr.getTransactionThinkTime("Demo"));

        lr.endTransaction("Demo", lr.AUTO);
        actualElapsedTime = lr.endTimer(MasterT);
        lr.outputMessage("Total Elapsed time for Action = " + actualElapsedT

        return 0;
    }

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: