Jump to content
Barand

"Separation of Concerns" at a cost

Recommended Posts

Around the turn of the century I had just discovered PHP and was currently using ASP with VB for intranet applications. One particular page enabled users to view log entries each day. This had worked fine for months when I received a complaint from one of the users that it was running very slowly. I tried it myself and, sure enough, it took about 15 seconds to display the data.
Examining the entries in the SQL Server table for that day I noticed that there were some abnormally long text entries, way longer than usual. Curious about the time taken I decided to write the application in PHP (for the practice if nothing else) and see if that improved things.
It did.
For the same day, the screen displayed in 0.25 seconds. That was 70 times faster! Too good to be true, I thought. So I compared the two programs.
The structure of the ASP program was

loop
    get record
    concatenate output into a string
endloop
outout the string


The PHP structure was

loop
    get record
    output 
endloop


The ASP structure was a better "separation of concerns" which is the method usually preached, but it did come at a cost as further experimentation was to prove.
My next task was to rewrite the ASP using the PHP structure and vice versa so that I could get a much fairer comparison.
As the chart below shows, concatenating does have an overhead (especially with long strings) and this is even more marked with VB which seemed extremely poor at handling the task.

concatenation_costs.PNG.a3299e27c5a1a3394b6864aff9a766da.PNG

 

Edited by Barand

Share this post


Link to post
Share on other sites

I really wouldn't have expected ASP Classic to be that bad at handling strings - I mean sure, strings are immutable, but reallocating that much bringing a 10x decrease in performance?

While I was looking up whether it has some equivalent to StringBuilder (it doesn't) I found this that you might find interesting.

Share this post


Link to post
Share on other sites
1 hour ago, requinix said:

I really wouldn't have expected ASP Classic to be that bad at handling strings

Bad enough that someone felt the need to publish an article about it!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.