Correlation - HP LoadRunner 12.50
Correlation vs. Parameterization
Parameterization is used when to take a value and turn it into a variable in order to make your script more realistic. For example, if we are filling out a form on a website, you may want to vary the value entered for a particular field.
Correlation is used when a recorded script includes a dynamic value (such as a session ID) and cannot replay. To resolve this, you make the dynamic value into a variable thereby enabling your script to replay successfully.
Which values to correlate
Once a list of differences is generated, determine which ones to correlate. The following strings most probably require correlation:
- A login string with dynamic data such as a session ID or a timestamp.
- Any string using a date or time stamp, or other user credentials.
- A common prefix, such as SessionID or CustomerID, followed by a string of characters.
If we are in doubt whether a difference should be correlated, correlate only that difference and then run your script. Check the Replay log to see if the issue was resolved. We should also correlate differences in which some of the recorded and replayed strings are identical, but others differ. For example, SessionID strings with identical prefixes and suffixes, but different characters in between, should be correlated.
Wdiff
The Wdiff utility compares recorded Vuser scripts and replay results to determine which values need to be correlated.
Record the identical operation twice, then compare the scripts (or data files for WinSock). WDiff displays differences in yellow. Note that not all differences indicate a value to correlate. For example, certain receive buffers that indicate the time of execution do not require correlation.
Arithmetic operations
To perform arithmetical operations on a saved parameter, change the parameter from a string to an integer using the atoi or atol C functions. After modifying the value as an integer, to used it in your script, convert it back to a string. In the following WinSock example, the data at offset 67 was saved to the parameter, param1. Using atol, VuGen converted the string to a long integer. After increasing the value of param1 by one, VuGen converted it back to a string using sprintf and saved it as a new string, new_param1. The value of the parameter is displayed using lr_output_message. This new value may be used at a later point in the script.
lrs_receive("socket2", "buf47", LrsLastArg);lrs_save_param("socket2", NULL, "param1", 67, 5);
lr_output_message ("param1: %s", lr_eval_string(""));
sprintf(new_param1, "value=%ld", atol(lr_eval_string("")) + 1);
lr_output_message("ID Number:"%s" lr_eval_string("new_param1"));
Manual correlation
To manually correlate a script...
- Search for values that need correlation manually.
- Correlate the value using one of the following methods...
- Correlate from snapshots. Highlight the value to correlate, right-click, and select Create Correlation.
When a value is correlated, VuGen adds the correlation parameter and saves the original value in a comment in the script.
- Manually add correlation functions.