Hidden gem in Alpha Five can improve performance up to 100 to 200 percent
Before I get into this, I just want to ask you for one favor. If you run into me at a trade show, don't hit me for keeping this great function a secret from you. I, myself, only just found out about it when it showed up in Alphapedia, our wiki-based, context-sensitive help system.
Confused as to why this particular function was never documented before, I enlisted Clifton to sniff out who was responsible. His nose led me straight to Dr. Martin Heller who was able to provide a detailed explanation: Oops, we forgot. For that oversight he'll have to share part of his lunch with Clifton from now on. ;)
Now, let me tell you what you've been missing. The compilestringtemplate() function can double, triple, or quadruple the performance of your Web application, depending upon the complexity of the template. Now, if you're using the standard Ajax Grids, then this won't help you because the function has been used internally since it was written.
This function helps developers who are generating their own HTML programmatically. That's because they usually want a lean, mean, and speedy display and don't need all the editing features of the Grid. Developers coding their Web applications by hand sometimes create a database query and then generate some HTML content to send to the browser. The HTML content is often generated by merging data from the database into an HTML template. The evaluate_string() function is used because it's ideal for merging data into a template.
However, in a case where the HTML content is constructed by looping over the records in the query and merging data into the template for each row in the query, using the compilestringtemplate() function can be more efficient. With it, you can compile the merge code once and then run it against multiple data rows. And the more complex the template, and the more iterations there are, you could easily see an improvement of 100 to 200 percent.
I'm not going to repeat what's in Alphapedia, so head over to the entry for a full description. Then give it a try yourself and let me know what you think.
Confused as to why this particular function was never documented before, I enlisted Clifton to sniff out who was responsible. His nose led me straight to Dr. Martin Heller who was able to provide a detailed explanation: Oops, we forgot. For that oversight he'll have to share part of his lunch with Clifton from now on. ;)
Now, let me tell you what you've been missing. The compilestringtemplate() function can double, triple, or quadruple the performance of your Web application, depending upon the complexity of the template. Now, if you're using the standard Ajax Grids, then this won't help you because the function has been used internally since it was written.
This function helps developers who are generating their own HTML programmatically. That's because they usually want a lean, mean, and speedy display and don't need all the editing features of the Grid. Developers coding their Web applications by hand sometimes create a database query and then generate some HTML content to send to the browser. The HTML content is often generated by merging data from the database into an HTML template. The evaluate_string() function is used because it's ideal for merging data into a template.
However, in a case where the HTML content is constructed by looping over the records in the query and merging data into the template for each row in the query, using the compilestringtemplate() function can be more efficient. With it, you can compile the merge code once and then run it against multiple data rows. And the more complex the template, and the more iterations there are, you could easily see an improvement of 100 to 200 percent.
I'm not going to repeat what's in Alphapedia, so head over to the entry for a full description. Then give it a try yourself and let me know what you think.



1 comments:
The Alpha e-commerce application includes a hand coded navigation component, so I tried rewriting it using this function. I can confirm that it was easier to code than the original coding and blazing fast!
Post a Comment