lr_resume_transaction
Resumes reporting transaction data within a script.
void lr_resume_transaction( char *transaction_name);
| Alphabetical Listing - C Language Utility Functions |
Arguments
| Name | Comments |
|---|---|
| transaction_name | The name of the transaction. |
This function is retained for backward compatibility. For more general ways of reporting partial transaction durations, see lr_start_sub_transaction and lr_set_transaction.
The lr_resume_transaction function resumes the reporting of transaction data within the script that was suspended by lr_stop_transaction. After a call to lr_stop_transaction, statistics returned by the "get" Transaction Functions reflect only the data up to that call, until this function is called.
Data collection, however, is not interrupted. After the call to lr_resume_transaction, the "get" functions return all data since the start of the transaction. 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 is not called, the "get" functions and the final results reflect only the duration from the transaction start to the lr_stop_transaction call. Thus, lr_stop_transaction and lr_resume_transaction can be used conditionally to collect information either about an entire transaction, or only the beginning. To accomplish this, call lr_resume_transaction only if your condition is met.
Note: When data is collected this way, the data in analysis will reflect both the tests where the condition for lr_resume_transaction is met, and the tests where it is not.
If the section you may wish to exclude ends before the end of the transaction, this technique does not apply. If you need to differentiate between occurrences where the lr_resume_transaction condition is met and those where it is not in the analysis data, this technique does not apply.
For other ways of recording durations conditionally, see lr_start_sub_transaction and lr_set_transaction.
Return Values
No value is returned.
Parameterization
You cannot use standard parameterization for any arguments in this function.
Example
In the following example, a transaction is stopped and resumed to show the effect on the reported duration.
Action() {
int i;
int iteration = 100;
char aStr[100];
lr_start_transaction("Stop&Start");
/* Do part of business process. Represented
here by loop to ensure that some
time passes. */
for (i=0; i < iteration; ++i) {
sprintf(aStr, "%d", i);
lr_log_message("%d",i);
} /* Output the duration to this point (0.343750 seconds)
with transaction active. */
lr_output_message("First time = %f",lr_get_transaction_duration("Stop&Start"));// Stop the transaction
lr_stop_transaction("Stop&Start"); /* Output the duration to this point (0.359375 seconds)
with transaction stopped. */
lr_output_message("Immediately after stop = %f", lr_get_transaction_duration("Stop&Start"));// Ensure that some time passes
for (i=0; i < iteration; ++i) {
sprintf(aStr, "%d", i);
lr_log_message("%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", lr_get_transaction_duration("Stop&Start"));// Resume the transaction
lr_resume_transaction("Stop&Start");/* 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", lr_get_transaction_duration("Stop&Start"));// Add time to duration
for (i=0; i < iteration; ++i) {
sprintf(aStr, "%d", i);
lr_log_message("%d",i);
}/* Total time reported (1.140625 seconds) */
lr_output_message("After resume and loop = %f", lr_get_transaction_duration("Stop&Start")); // End transaction
lr_end_transaction("Stop&Start", LR_AUTO);
return 0;
}Example: Output:
Action.c(11): Notify: Transaction Stop&Start started.
Action.c(23): First time = 0.343750
Action.c(27): Notify: Transaction Stop&Start stopped.
Action.c(31): Immediately after stop = 0.359375
Action.c(45): After stop and loop = 0.359375
Action.c(49): Notify: Transaction Stop&Start resumed.
Action.c(55): After resume time = 0.781250
Action.c(65): After resume and loop = 1.140625
Action.c(70): Notify: Transaction Stop&Start ended with Pass status (Duration: 1.1406).

