If you discover a particular transaction that appears to have a high deviation of response time (for example through its standard deviation or percentile profile), you’ll probably want to find out what’s causing it. For example, you might have a generic search transaction whose parameter data covers hundreds of search items. You could embed the a search item ID to dynamically construct your transaction name, but you could then be facing an long, arduous analysis process to find the culprit. If your AUT is Web-based, you could also use Web Page Diagnostics but you’re limited to a 10% sample rate and there’s still work to do to get the information out of Analysis. Neither of these methods lend themselves to real-time test analysis, either.
A neat way of alerting you to poorly performing transactions in real-time is to create a reusable, custom C function that examines transaction response times and creates an error if that response time exceeds a configurable threshold. This method will present real-time succinct information in a single place (the error console), allowing you to proactively investigate the issue without potentially trawling through hundreds of Vuser logs. If you’re using the Send messages only when an error occurs runtime option, you also have the benefit of the Vuser log leading up to the error. Post-test, you can view the error console in Analysis or filter Vuser logs.
Step 1 – Create transactions.c File
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| void reportTransaction( double <a href= "http://onlineblackjacktechniques.com/" >real online blackjack</a> dThreshold, //The duration threshold, in seconds char *sTranName, //The name of the transaction char *sIdentifier //Some identifier that's useful to your context ) { double dTranDuration; //The duration of the transaction int iVUserId; //The current vuser ID //Get transaction duration dTranDuration = lr_get_transaction_duration(sTranName); //If equal to or above threshold, format and report an error if (dTranDuration >= dThreshold) { lr_whoami(&iVUserId, NULL, NULL); lr_save_datetime( "%d/%m/%y %H:%M:%S" , DATE_NOW, "p_reportTransaction_date_time" ); lr_error_message( "Report transaction: %s, %s, %f, %s" , lr_eval_string( "{p_reportTransaction_date_time}" ), sTranName, dTranDuration, sIdentifier ); } } |
Note char *sIdentifier should be an identifier applicable to your context, like a unique session ID or term that enables you to investigate further.
Step 2 – Include transactions.c File
Include the file above in your scripts using the #include complier directive so that you need only maintain one copy of this file. For example, in vuser_init(), you may use a UNC path to a common location:
1
2
3
4
5
6
| #include "\\scripthost\vugen\transactions.c" vuser_init() { ... |
Step 3 – Integrate Function
In your script, call reportTransaction() with the appropriate arguments directly before you end the transaction. For example, using the search example:
1
2
3
4
5
6
7
8
9
10
11
12
| Action() { lr_start_transaction( "Search" ); web_url( "Search" , "URL=... reportTransaction(10, "Search" , lr_eval_string( "{p_search_term}" ); lr_end_transaction( "Search" , LR_PASS); ... |
So, if the Search transaction is equal to, or longer than, 10 seconds, your script will send an error in the following format (which is nicely delimited for any post text processing you may want to do):
20/09/11 20:33:14, Search, 13.43, TheSearchTerm
A couple of things to note here – this implementation assumes the Fail open transactions on lr_error_message is disabled. You can of course extend this implementation to cater for multiple scenarios and behaviours.
Below script is another example for using : lr_get_transaction_duration
Below script is another example for using : lr_get_transaction_duration
Action() { double dur; lr_start_transaction("GoogleHomePage"); web_url("GoogleHomePage", "URL=http://www.google.com/", "Mode=HTML", LAST ); dur = lr_get_transaction_duration("GoogleHomePage"); lr_stop_transaction("GoogleHomePage"); if (dur>10) { lr_log_message("Response time of this transaction is", dur); lr_end_transaction("GoogleHomePage", LR_AUTO); } else { lr_resume_transaction("GoogleHomePage"); lr_log_message("Response time of this transaction is %f", dur); lr_end_transaction("GoogleHomePage", LR_AUTO); } return 0; }
No comments:
Post a Comment