我正在使用适用于HP Performance Center的虚拟用户生成器,但我无法找出lr_start
/ end_transaction
和lr_start
end_transaction_instance
之间的区别。我所能得到的支持就是交易用于跟踪持续时间"和事务实例用于"性能分析",但我似乎无法找到分析结果的差异。
这两者之间有明显的区别吗?如果是这样,我可以看一个简短的例子吗?
答案 0 :(得分:1)
LoadRunner 事务用于衡量某些语句执行之间的时间。
LoadRunner 事务实例用于对您在脚本中声明的现有事务进行性能分析。您可以按名称将事务放入变量中,以后可以用它来分析其状态:获取其当前持续时间,状态等。
示例:强>
long id;
int status;
int amount_overdrawn = get_amount_overdrawn(); // Call some API
while (amount_overdrawn < LIMIT) {
// Notify that a transaction is starting
lr_start_transaction("withdraw");
status = bank_withdraw(500); // Call some API
// End transaction with operation result - pass or fail
if (status == 0)
lr_end_transaction("withdraw", LR_PASS);
else
lr_end_transaction("withdraw", LR_FAIL);
amount_overdrawn = get_amount_overdrawn();
}
// Set the transaction instance into a variable
id = lr_start_transaction_instance("withdraw", 0);
status = bank_withdraw(500);
// End the transaction instance using the same variable
lr_end_transaction_instance(id, LR_PASS);