Share this page

# lr.get_transaction_wasted_time

Returns the wasted time of a transaction by its name.

## Java

    Double lr.get_transaction_wasted_time( String transaction )

Transaction Functions | Java Syntax

## Arguments

Name | Comments
--- | ---
transaction | The name of the transaction.

The lr.get_transaction_wasted_time function returns the Wasted Time in seconds of the specified transaction to this point. It only returns values greater than zero only for open transactions.

To determine other transaction statistics, such as think time and wasted time, use the appropriate Transaction function.

## Return Values

If this function succeeds, it returns the transaction wasted time in seconds. If it fails, it returns a negative number. If the transaction already ended or if data is not available for the specified transaction, it returns 0.

## Parameterization

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

## Example

The following segment demonstrates the use of timers to generate and retrieve wasted time.

Copy code

    int i, baseIter = 1000;
    long wasteTime, actualElapsedTime;
    //merc_timer_handle_t MasterT, timer;
    long mainTimer, timer;

    // Examine the total elapsed time of the action
    mainTimer = lr.start_timer();

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

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

    // Add some think time
    lr.think_time(0.5);
    // Create some wasted time and record it with timer
    timer = lr.start_timer();

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

    wasteTime = lr.end_timer(timer);
    lr.output_message("User created waste time = " + wasteTime);
    lr.output_message("Before lr.wasted_time: Duration = " +
           lr.get_transaction_duration("Demo") + "- Waste = " +
           lr.get_transaction_wasted_time("Demo"));

    // Convert timer in seconds to wasted time in milliseconds and add to internally generated waste time */
    wasteTime *= 1000;
    lr.wasted_time(wasteTime);
    lr.output_message("After lr.wasted_time: Duration = " +
                lr.get_transaction_duration("Demo") + "- Waste = " +
                lr.get_transaction_wasted_time("Demo"));

    lr.output_message("Think time = " + lr.get_transaction_think_time("Demo"));
    lr.end_transaction("Demo", lr.AUTO);
    actualElapsedTime = lr.end_timer(mainTimer);
    lr.output_message("Total Elapsed time for Action = " + actualElapsedTime);

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: