Building Performance into Internet Applications

[article]

Optimized Logging
Server side logging can be expensive. The logging can be done in low, moderate, and high amounts. This is totally based on the architecture and the amount of debugging facility the product asks for. If every subroutine is logging entry and exit points, the cross boundary COM/COM+ calls can become expensive and can undermine overall product performance. Minimal logging can be useless from a developer's perspective. The balance has to be achieved somehow. This falls under designing, and product drives the need to implement it.

String Manipulation
String manipulations can be very expensive from a performance perspective. If ASP/JSP code is looping to formulate a string to send back to the client browser, efforts should be made to avoid this process. For example, many people build a string in a loop like this:

s = "

helps when the page is HTML based. However, with asp and jsp pages, it becomes too expensive to send all that data over the wire each time the request is made. The data can be dynamically displayed. No doubt, it is confusing and tedious from a programming perspective to use "document.write" to render HTML, but it does save network bandwidth as script files can be locally cached. There are many cascading style sheet editors on the market to facilitate this process of attaching cascading style sheets to HTML/ASP/JSP pages.

For Each fld in rs.Fields

s = s & "

Next

While Not rs.EOF

s = s & vbCrLf & "

For Each fld in rs.Fields

s = s & "

Next

s = s & "

rs.MoveNext

Wend

s = s & vbCrLf & "

" & vbCrLf""""

" & fld.Name & "
" & fld.Value & "

" & vbCrLf

Response.Write s

There are several problems with this approach. The first is that repeatedly concatenating a string takes quadratic time; less formally, the time that it takes to run this loop is proportional to the square of the number of records, times the number of fields. A simpler example should make this clearer:

s = ""

For i = Asc("A") to Asc("Z")

s = s & Chr(i)

Next

About the author

TechWell Contributor's picture TechWell Contributor

The opinions and positions expressed within these guest posts are those of the author alone and do not represent those of the TechWell Community Sites. Guest authors represent that they have the right to distribute this content and that such content is not violating the legal rights of others. If you would like to contribute content to a TechWell Community Site, email editors@techwell.com.

About the author

Arvind Rajaram's picture Arvind Rajaram

Arvind Rajaram is a senior programmer analyst. He has more than five years' experience in software development, quality assurance, and automated testing. He has a master's degree in engineering from Brooklyn Polytechnic, NY, and has worked as a performance engineer for several projects. You can contact Arvind at arvindrajaram@yahoo.com.

AgileConnection is one of the growing communities of the TechWell network.

Featuring fresh, insightful stories, TechWell.com is the place to go for what is happening in software development and delivery.  Join the conversation now!