lr_stop_transaction_instance
Freezes reporting statistics for a transaction instance specified by its handle.
double lr_stop_transaction_instance (long parent_handle);
| Alphabetical Listing - C Language Utility Functions |
Arguments
| Name | Comments |
|---|---|
| parent_handle | A unique transaction handle. |
After a call to lr_stop_transaction_instance, statistics returned by the "get" Transaction Functions reflect only the data up to the call, until lr_resume_transaction_instance is called. The specified transaction instance must have been opened with lr_start_transaction_instance.
Data collection, however, is not interrupted. After the call to lr_resume_transaction_instance, the "get" functions return all data since the start of the transaction instance. 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_resume_transaction_instance is not called, the final results reflect the statistics only until the call to lr_stop_transaction_instance.
The parent_handle is the value returned from the call to lr_start_transaction_instance that created the instance.
lr_stop_transaction_instance and lr_resume_transaction_instance can be used to conditionally collect information about either the beginning, or all of the transaction.
Note that you will not be able to differentiate in analysis between iterations when lr_stop_transaction_instance was called and iterations where it was not.
For more flexible ways recording transaction times conditionally, see lr_start_sub_transaction, lr_set_transaction,and lr_start_timer.
Return Values
This function returns the duration of the current transaction instance in seconds if it succeeds, and a negative number if an error occurs.
Parameterization
Parameterization is not applicable to this function.
Example
The following example shows the effect of lr_stop_transaction_instance and lr_resume_transaction_instance.
StopResumeInstance() {
long hdl;
int i, baseIter = 100;
char dude[200];
double dur;
hdl = lr_start_transaction_instance("Stop%Start", 0);
/* Do part of business process. Represented
here by loop to ensure that some
time passes. */
for (i=0; i< (10 * baseIter); ++i)
sprintf(dude, "Artificially add elapsed time = %d", i);
//Add 1/2 second waste time
lr_wasted_time(500);
/* Output the duration to this point (0.343750 seconds) with transaction active. */ lr_output_message("First time duration = %f, Waste = %f",
lr_get_trans_instance_duration(hdl),
lr_get_trans_instance_wasted_time(hdl)); // Stop the transaction
dur = lr_stop_transaction_instance(hdl);
lr_output_message("Duration from stop call = %f", dur);
//Add 1/2 second waste timelr_wasted_time(500);
/* Output the duration to this point (0.359375 seconds) with transaction stopped. */
lr_output_message("Immediately after stop = %f, Waste = %f",
lr_get_trans_instance_duration(hdl),
lr_get_trans_instance_wasted_time(hdl)); // Ensure that some time passes
for (i=0; i< (10 * baseIter); ++i) sprintf(dude, "Artificially add elapsed time = %d", 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_output_message("After stop and loop = %f, Waste = %f",
lr_get_trans_instance_duration(hdl),
lr_get_trans_instance_wasted_time(hdl));// Resume the transaction
lr_resume_transaction_instance(hdl);
/* 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_output_message("After resume time = %f, Waste = %f",
lr_get_trans_instance_duration(hdl),
lr_get_trans_instance_wasted_time(hdl)); // Add time to duration
for (i=0; i< (10 * baseIter); ++i) sprintf(dude, "Artificially add elapsed time = %d", i);
/* Total time reported (1.140625 seconds) */
lr_output_message("After resume and loop = %f, Waste = %f",
lr_get_trans_instance_duration(hdl),
lr_get_trans_instance_wasted_time(hdl)); // End transaction
lr_end_transaction_instance(hdl, LR_AUTO); return 0; }
Example: Output:
First time duration = 0.609375, Waste = 0.500000
Notify: Transaction Stop%Start stopped.
Duration from stop call = 0.625000
Immediately after stop = 0.625000, Waste = 0.500000
After stop and loop = 0.625000, Waste = 0.500000
Notify: Transaction Stop%Start resumed.
After resume time = 1.265625, Waste = 1.000000
After resume and loop = 1.875000, Waste = 1.000000
Notify: Transaction Stop%Start ended with Pass status (Duration: 1.8750 Wasted Time: 1.0000).

