transactionsloadrunnervugen

What is the difference between a transaction and a transaction instance in Vugen?


I am using the Virtual User Generator for HP Performance Center, and I can't figure out the difference between lr_start / end_transaction and lr_start end_transaction_instance. All I can find in support is that the transaction is used for "tracking duration" and transaction instance is used for "performance analysis", but I can't seem to find a difference in analysis results.

Is there a noticeable difference between these two? If so, may I see a short example?


Solution

  • A LoadRunner transaction is used to measure time between executions of certain statements.

    A LoadRunner transaction instance is used for performance analysis of an existing Transaction you declared in your script. You place the Transaction, by name, into a variable, that can later be used to analyze its status: Get its current duration, status, etc.

    Example:

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