Example: lr_get_trans_instance_wasted_time

In the following example, the lr_get_trans_instance_wasted_time function gets the wasted time of a transaction, and sends it to the Output window.

#include "as_web.h"
Action() {
    long parent_trans_handle;
    double trans_time;
    int rc;
    /* Start the main transaction instance.
        Passing 0 as the parent handle indicates that the 
        transaction has no parent.
        The function return value is the handle used in other 
        transaction instance functions.     */
    parent_trans_handle =  lr_start_transaction_instance("ParentTransaction",0);

    /*Perform the business process, represented here with a single web_url call. */
    web_url("web_url", "URL=http://www.ABC.com",LAST ); 
    rc = lr_get_trans_instance_status(parent_trans_handle);
    if (rc == LR_FAIL) {
     /* web_url has failed the transaction. 
        No point in continuing, because
        future calls will probably also fail. */
     lr_end_transaction_instance(parent_trans_handle, LR_FAIL);
     return;
    }
    /* Get the transaction instance durations. 
        Pass the instance handle. 
        The duration in seconds is the return value. */
    //Total duration
    trans_time = lr_get_trans_instance_duration(parent_trans_handle);
    lr_output_message("Instance time is %lf seconds.", trans_time);
    //Think time
    trans_time = lr_get_trans_instance_think_time(parent_trans_handle);
    lr_output_message("Instance think time is %lf seconds.", trans_time);
    //Wasted time
    trans_time = lr_get_trans_instance_wasted_time (parent_trans_handle);
    lr_output_message("Instance waste time is %lf seconds.", trans_time);
    //End the transaction instance
    lr_end_transaction_instance(parent_trans_handle, LR_PASS);
    return 0;
}