Using system memory for test data parameters at run time
In case of very large data pools, where the number of records for each type of test data is 100,000 or more with a specific pattern, it is better to use custom code, with logic based on the pattern, to parameterize runtime data in the script, rather than creating a data pool. The data pool is a file that contains the test data. It needs to be transferred from the workbench machine to the agents and read at run time by the agents to the generated load, using the test data in the file. These read operations involve heavy I/O activity during generation of high throughput requests, leading to significant CPU utilization on the operating system.
In this event, you cannot drive the desired amount of high throughput load by using the performance test software, because it "chokes" the operating system resources and becomes a bottleneck in running performance tests. To completely alleviate this I/O activity, you can use custom codes in the test scripts to generate data though quick computations (based on logic), where the data is stored and read from physical memory. Physical memory read/write operations are far faster than operations on disk, so this improves the overall performance of load generation requests.
Example: Generate data pools from system memory
Consider a simple example where the username for a web application needs to have parameters set. If the number of users is 100,000 or more, then it is best to generate a user ID on each iteration by executing logic with a common pattern. Follow the steps described here for implementation –
Identify a common pattern
Let's say that all user names start with the word username, followed by a number. For example: username1, username2, username3.
- Create a new test variable and initialize its value to
Username1, as Figure 1 shows:- Open the test script.
- Click on the Test Variables section and expand it.
- Notice the test variables listed below Test Variables section. If there are none, click Add when Test Variables is selected.
- Click Variable Declaration so that you can add a new variable.
Figure 1. Creation of new test variable in Rational Performance Tester
Figure 2. Note that you can initialize a test variable to a text or data pool value
Create custom code
- Create a custom code in the page that loads after logging into the application, and paste the code from Listing 1 in the exec method of the custom code class.
Listing 1. Exec method in the custom code
public String exec(ITestExecutionServices tes, String[] args) {
/**
* This code snippet obtains the previously used username for logging into the
application and increments it by 1 to get the next username in the test data
*/
String number = "";
/**
* The assumption here is that all usernames begin with the word - "Username" and
has '8' characters in it.
* Variable "number" is the value 'n' for 'nth' user or nth row of the data pool or can
be also thought of as the 'nth' iteration of the test
*/
for (int i=0;i<((args[0].length())-8);i++)
{
number+=Character.toString(args[0].charAt(8+i));
}
int num = Integer.parseInt(number);
num++;
return "Username"+Integer.toString(num);
/**
* This returns the username appended with the next value of 'n' in the 'nth' iteration
*/
}
|
- In the Custom Code – Select Arguments window, under Test Variables, check the box by Username_Variable to add it as the argument to this custom code, as Figure 3 shows.
Figure 3. Addition of the Username variable as an argument to custom code
- Select the Username variable in the list of data pool variables on the page that loads after logging in, and substitute the same from the custom code as Figure 4 shows:
- Select the page that shows the Username variable as test data. Tip: Another way to find out whether the Username variable is a test data or not is by looking at its color code. The color code adopted in Rational Performance Tester software for variables that can be parameterized at run time is green.
- Select the username variable under test data table.
- Click the Substitute button and choose Custom code in the list of options as shown.
Figure 4. Substitution of the username variable with output of the custom code
- Assign the variable to the custom code by inserting Variable assignment (see Figure 5). A test variable must be reused in the test script. This means that its value needs to be updated with the new value whenever logic is executed. To update the value, follow these steps:
- Select the custom code that will change the test variable data when it is executed.
- Click Insert, select Variable Assignment.
Figure 5. Username variable assignment to the custom code
- Select the Username_Variable from the list of options, and set the Username_Variable to the output of the custom code by clicking the DataSource Value radio button and selecting the custom code in the options provided.
When this test is launched, the Username variable in the test will be substituted from the value returned by the execution of the custom code at run time.
Important:
Inserting the variable assignment is crucial in ensuring that the updated value of the global variable in the custom code takes effect after exiting the custom code, when the assignment of the global variable happens.
By doing this, large data pool file sizes and corresponding I/O activity can be avoided. This also improves the performance Rational Performance Tester agent in generating the test load, because the data pool values are served faster from memory than from disk, thereby alleviating disk reading latencies.
Note:
For the "Visible in" field, if the test script is looped at a schedule level, select the option for All tests for this user, and if the loop is within the test script, select the This test only option, as shown in Figure 6.
Figure 6. Different levels of visibility of the test Username variable
In scenarios where there is a good likelihood of some of the test data being repeated over and over again for many iterations, it is better to store the data pool entries (row entries) in a variable string array, and read the values from this array and substitute at run time.
This approach prevents performance degradation from repeated data read I/O on the data pool files due to disk latencies. Instead, it reads the data from physical memory, which is much faster to access and leads to better performance of the Rational Performance Tester agent.
Other good practices to adopt for large volume data pools
- When there is a test scenario that requires parameters for many values (usually > 30-40 values), then it is better not to use a monolithic large data pool file. Instead, use many small data pool files in which the entire test data is divided and organized by the variables, with parameters set at run time.
This helps in increased parallel operation in I/O while reading test data from the data pools hence leading to better performance of Rational Performance Tester agents. - Although it is good to use custom codes for data parameters, this option should be carefully chosen wherever applicable. This is because custom codes create significant overhead (primarily on process utilization and memory) during testing, depending on the complexity of the logic executed in the code and the number of such custom code segments.
- For scripts that are already heavy in terms of many custom codes, correlations, and so forth, avoid Content verification points insofar as possible, because using them parses the entire response from the server to validate certain criteria. Parsing of the entire response for a limited-length string consumes significant CPU resources to run the process. Use Response Code or Title verification points wherever possible, instead.
Learn
- Find out more on the Rational Performance Tester product overview page. Then explore the Rational Performance Tester page on IBM® developerWorks® for links to technical articles and browse the user assistance in the Rational Performance Tester Information Center.
- Visit the Rational software area on developerWorks for technical resources and best practices for Rational Software Delivery Platform products.
- Stay current with developerWorks technical events and webcasts focused on a variety of IBM products and IT industry topics.
- Attend a free developerWorks Live! briefing to get up-to-speed quickly on IBM products and tools, as well as IT industry trends.
- Watch developerWorks on-demand demos, ranging from product installation and setup demos for beginners to advanced functionality for experienced developers.
- Improve your skills. Check the Rational training and certification catalog, which includes many types of courses on a wide range of topics. You can take some of them anywhere, any time, and many of the "Getting Started" ones are free.
Get products and technologies
- Download the trial version of IBM Rational Performance Tester.
- Evaluate IBM software in the way that suits you best: Download it for a trial, try it online, use it in a cloud environment, or spend a few hours in the SOA Sandbox learning how to implement service-oriented architecture efficiently.
Discuss
- Join the Performance Testing forum, where you can share you questions and knowledge about IBM performance testing products.
- Share your knowledge and help others who use Rational software by writing a developerWorks article. You'll get worldwide exposure, RSS syndication, a byline and a bio, and the benefit of professional editing and production on the developerWorks Rational website. Find out what makes a good developerWorks article and how to proceed.
- Follow Rational software on Facebook and Twitter (@ibmrational), and add your comments and requests.
- Ask and answer questions and increase your expertise when you get involved in the Rational forums, cafés, and wikis.
- Connect with others who share your interests by joining the developerWorks community and responding to the developer-driven blogs.

Bharath Raj works at the IBM India Software Labs with the HiPODS team (High Performance On Demand Solutions) as an enterprise solutions performance analyst. He started his career with IBM as a J2EE application developer using Web 2.0 technologies. He continued into the role of performance of middleware, Java, and databases used for enterprise solutions in telecom, retail, and other applications. With an intensive background and experience on Performance Tuning, Capacity planning and Sizing, Testing and Performance Engineering methodologies, Bharath brings a holistic end-to-end Topology from anything and everything in performance of an Enterprise solution, as well as design and review of the solutions based on performance. He continues to use cutting edge technologies in enterprise web applications to achieve an optimized, faster, and a much more reliable solution.




