lr_get_trans_instance_duration
Returns the duration of a transaction instance.
double lr_get_trans_instance_duration (long trans_handle);
| Alphabetical Listing - C Language Utility Functions |
Arguments
| Name | Comments |
|---|---|
| trans_handle | A transaction handle. |
The lr_get_trans_instance_duration function returns the duration of an open transaction instance in seconds until this point. Use this function to determine the total transaction time before the transaction has ended.
The difference between this function and lr_get_transaction_duration is that with this function you specify a transaction instance by its handle. With lr_get_transaction_duration, you specify an independent transaction by its name.
The trans_handle is the return value of a call to lr_start_transaction_instance.
lr_get_trans_instance_duration 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 Functions.
Return Values
If this function succeeds, it returns the transaction duration. 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
In the following example, the lr_get_trans_instance_duration function checks the durations of parent and child transaction instances, and sends them to the Output window.
#include "as_web.h"
Action() {
long parent_trans_handle;
long child_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;
}/* Start the child transaction instance. Passing the handle returned from another lr_start_transaction_instance call as the handle argument makes this transaction a child instance. */
child_handle = lr_start_transaction_instance("ChildTransInstance",parent_trans_handle);
// Perform the business process
web_url("web_url","URL=http://ABC.com",LAST );/* Get the child transaction instance durations. Pass the instance handle. The duration in seconds is the return value. */
trans_time = lr_get_trans_instance_duration(child_handle);
lr_output_message("First child instance time is %lf seconds.", trans_time); //Think time
trans_time = lr_get_trans_instance_think_time(child_handle);
lr_output_message("First child instance think time is %lf seconds.", trans_time); //Wasted time
trans_time = lr_get_trans_instance_wasted_time (child_handle);
lr_output_message("First child instance waste time is %lf seconds.", trans_time);// End the child transaction instance
lr_end_transaction_instance(child_handle, LR_PASS);
/* Get the Parent transaction instance duration, which includes the child transaction duration. */
trans_time = lr_get_trans_instance_duration(parent_trans_handle);
lr_output_message("Parent Transaction duration is %lf seconds.", trans_time );//End the parent transaction instance lr_end_transaction_instance(parent_trans_handle, LR_PASS); return 0; }

