|
|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV SYS-CON.TV WEBCASTS |
POWERBUILDER LINKS YOU MUST CLICK ON PB & Java
If Your Strings Don't Zing
By: Shari Brandhoy
Digg This!
Many PowerBuilder developers have tried writing Web applications in EAServer, building long strings of HTML in their components to create on-the-fly Web pages. Sometimes you get good response time...and sometimes the response time gets you. We were building pages with 40 or more rows of data and 8-10 columns. With heading, table, and other HTML tags, we were approaching 800-1000 concatenation operations in a single function call. Response time was bad, so we tried a number of approaches to improve it. We used one string variable within the loop and concatenated it 40 times (once for each row) to the longer string that was to be the final page. This produced some improvement, but we wanted more. It seemed to be the number of concatenations performed when building our large HTML string that was slowing us down. We were also using a Java session bean and were starting to code more in Java. We knew that the String Buffer object in Java had an append method, so we decided to try the following:
This approach seemed a little farfetched. We were going to loop though all the data twice, once to build the array in PowerBuilder and again to append the strings in Java. The strange thing was that it worked, and the difference between the two methods became even more dramatic as the number of concatenations increased. We built a small application to further test our results. In this application we could specify the number of concatenations, the length of the string, and other test parameters. We found that when the number of concatenations is small, PowerBuilder is faster. However, as the number of concatenations approaches 400-500, the execution time for the methods is nearly the same. When it exceeds 400-500, building an array in PowerBuilder, passing it to Java, and concatenating it in Java is much faster than performing the concatenation in PowerBuilder. We performed 1,700 tests each in Java and PowerBuilder, using the system timer. Figure 1 shows the results of one of our trials. All tests were performed on the same hardware. In each test we measured the time from when the request began to when the HTML string was ready to display in the browser. We found that our test results were relatively insensitive to the length of the string being concatenated except that the longer the strings, the more extreme the differences. It's definitely worth the added time to code Java to handle the concatenation when you're dealing with over 400 concatenation operations.
PBDJ LATEST STORIES . . .
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING POWERBUILDER / SYBASE NEWS
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||