1

我正在使用 HP Performance Center 的虚拟用户生成器,但我无法弄清楚lr_start/end_transactionlr_start end_transaction_instance. 我在支持中只能找到事务用于“跟踪持续时间”,事务实例用于“性能分析”,但我似乎无法找到分析结果的差异。

这两者之间有明显的区别吗?如果是这样,我可以看一个简短的例子吗?

4

1 回答 1

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);
于 2017-03-23T18:25:09.797 回答