loadrunner Lr_类函数之 lr_stop_transaction_instance()

lr_stop_transaction_instance()

终止由其句柄指定的事务实例的报告统计信息。

double lr_stop_transaction_instance(long parent_handle);

 

参数说明:

parent_handle:唯一的事务句柄。

 

调用lr_stop_transaction_instance后,由“get”事务函数返回的统计信息只反映直到调用的数据,直到调用lr_resume_transaction_instance。指定的事务实例必须已使用lr_start_transaction_instance打开。

但是,数据收集不会中断。在调用lr_resume_transaction_instance之后,“get”函数自事务实例开始后返回所有数据。此外,分析测试时的最终结果将反映总值,包括交易停止和恢复之间的期间。

如果未调用lr_resume_transaction_instance,则最终结果仅反映到调用lr_stop_transaction_instance之前的统计信息。

parent_handle是从对创建实例的lr_start_transaction_instance的调用返回的值。

lr_stop_transaction_instance和lr_resume_transaction_instance可用于有条件地收集有关开始或所有事务的信息。

请注意,在调用lr_stop_transaction_instance时,您将无法区分迭代之间的分析,也可能无法区分迭代。

要更灵活地有条件地记录事务时间,请参阅lr_start_sub_transaction,lr_set_transaction和lr_start_timer。

lr_stop_transaction_instance返回实例的持续时间(以秒为单位)。

 

示例:lr_stop_transaction_instancelr_resume_instance

以下示例显示lr_stop_transaction_instance和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 time

lr_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;

 

}输出:

第一持续时间= 0.609375,废物= 0.500000

通知:事务停止%开始停止。

从停止呼叫的持续时间= 0.625000

停止后立即= 0.625000,废物= 0.500000

停止和循环= 0.625000后,Waste = 0.500000

通知:事务停止%开始继续。

在恢复时间= 1.265625之后,Waste = 1.000000

在恢复和循环= 1.875000之后,Waste = 1.000000

通知:事务停止%开始以通过状态结束(持续时间:1.8750浪费时间:1.0000)。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值