iTP Active Transaction Pages (iTP ATP) Programmer's Guide

Designing and Debugging ATP Applications
iTP Active Transaction Pages (iTP ATP) Programmer’s Guide522292-002
6-2
Designing for Performance
Concatenate Strings Before Printing
Minimize the use of atp.print by concatenating strings before printing them.
See Example 6-1
.
For large strings, it can be most efficient to use commas (,) instead of plus signs (+)
in print statements. A plus sign forces ATP to build an intermediate string, whereas a
comma allows the print function to iterate internally through the fields.
Let ATP Pass HTML to Browser
Do not explicitly print HTML statements to the browser. If you include HTML in
the clear in your script, ATP automatically and efficiently prints the HTML to the
browser.
Use Multiple Pages for Complex Scripts
If your script is long, split it across multiple web pages. Reducing the quantity of
script on each page helps performance, even though you are using more pages.
Use C Functions
For an operation that must occur on every transaction (for example, security
checking), consider writing a function in the C programming language to perform
the operation. For example, the function could be performed by a server class.
Whether this technique benefits performance depends on the complexity and other
characteristics of the operation.
Manage Memory During Long Loops
If your script uses long loops (more than 5000) iterations around explicit or implied
object constructors, consider using the JavaScript delete operator and the
atp.freeMemory() function to avoid heap buildup. See Example 6-2
.
Example 6-1. Concatenating Strings Before Printing
-str = 'some value';
str + 'more';
...
atp.print(str);
Example 6-2. Managing Memory During Long Loops
s1 = new atp.SQL("select * from =table for browse access ");
s1.execute();
for (limit=0; limit < 10000 && s1.next(); limit++) {
atp.print (s1.column_value, '<br>\n');
for (j=0;j<s1.column_value.length; j++) {
s1.column_value[i] = null;
delete s1.column_value[i];
}
if (limit % 100 == 0) atp.freeMemory();
}