473,795 Members | 3,358 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP Performance

I've read numerous articles, more than I can count, on ASP performance. I
see conflicting information so I did some tests on my own.

getstring and getrows are actually faster than recordset looping.

However, I've read in looping that Do While...Loop is the fastest and
For...Next the slowest but my tests prove otherwise.

I've tested:
Do...Loop
Do While...Loop
Do Until...Loop
While...Wend
For...Next

I didn't think I could do an accurate test with For...Each unless I used a
collection or an array.

I also see conflicting information on string concatenation and
Response.Write

Is this better?

dim str
str = str & "this "
str = str & "that "
str = str & "this and that"
Response.Write str

or this?

dim str
Response.Write "this "
Response.Write "that "
Response.Write "this and that"

I've also seen to speed the last one up:

with Response
.Write "this "
.Write "that "
.Write "this and that"
end with

Are there reliable performance tests that can be reviewed?
Does it vary between languages? ASP:VBscript, ASP:JScript, C/C++, Delphi,
VB, C#

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #1
31 2241
Roland Hall wrote:
Is this better?

dim str
str = str & "this "
str = str & "that "
str = str & "this and that"
Response.Write str

or this?

dim str
Response.Write "this "
Response.Write "that "
Response.Write "this and that"


Most definitely this is better than this.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 22 '05 #2
"Dave Anderson" wrote in message
news:ec******** ******@TK2MSFTN GP14.phx.gbl...
: Roland Hall wrote:
: > Is this better?
: >
: > dim str
: > str = str & "this "
: > str = str & "that "
: > str = str & "this and that"
: > Response.Write str
: >
: > or this?
: >
: > dim str
: > Response.Write "this "
: > Response.Write "that "
: > Response.Write "this and that"
:
: Most definitely this is better than this.

What this settles this but how about that?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #3
Roland Hall wrote:
I've read numerous articles, more than I can count, on ASP
performance. I see conflicting information so I did some tests on my
own.

getstring and getrows are actually faster than recordset looping.

However, I've read in looping that Do While...Loop is the fastest and
For...Next the slowest
I've never seen that anywhere. Do you have a cite?
but my tests prove otherwise.

I've tested:
Do...Loop
Do While...Loop
Do Until...Loop
While...Wend
For...Next

I didn't think I could do an accurate test with For...Each unless I
used a collection or an array.

I also see conflicting information on string concatenation and
Response.Write

Is this better?

dim str
str = str & "this "
str = str & "that "
str = str & "this and that"
Response.Write str

or this?

dim str
Response.Write "this "
Response.Write "that "
Response.Write "this and that"

I've also seen to speed the last one up:

with Response
.Write "this "
.Write "that "
.Write "this and that"
end with

Chris Hohmann (I think) posted the definitive analysis on this some time
ago. I don't have tome to go looking for it now, but maybe he'll pop in.
Regarding the With...End With, reducing the dots that need to be resolved
will speed things up, but
1. In vbscript, it's unlikely to be very noticeable
2. there is a threshold before which no performance enhancement will be
seen. I've seen 5 dot eliminations as the threshold but I really don't think
this has been nailed down by anyone.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #4
"Bob Barrows [MVP]" wrote in message
news:up******** ******@tk2msftn gp13.phx.gbl...

Thanks for responding...

: Roland Hall wrote:
: > I've read numerous articles, more than I can count, on ASP
: > performance. I see conflicting information so I did some tests on my
: > own.
: >
: > getstring and getrows are actually faster than recordset looping.
: >
: > However, I've read in looping that Do While...Loop is the fastest and
: > For...Next the slowest
:
: I've never seen that anywhere. Do you have a cite?

I think I had that wrong. I never found the article I thought I remembered
reading. Now I'm wondering if I was high. It must have been between Do
While...Loop and While...Wend and may not have been a speed comparison. If
you see my mind, please post it here. I miss it.

: > but my tests prove otherwise.
: >
: > I've tested:
: > Do...Loop
: > Do While...Loop
: > Do Until...Loop
: > While...Wend
: > For...Next
: >
: > I didn't think I could do an accurate test with For...Each unless I
: > used a collection or an array.
: >
: > I also see conflicting information on string concatenation and
: > Response.Write
: >
: > Is this better?
: >
: > dim str
: > str = str & "this "
: > str = str & "that "
: > str = str & "this and that"
: > Response.Write str
: >
: > or this?
: >
: > dim str
: > Response.Write "this "
: > Response.Write "that "
: > Response.Write "this and that"

No info on the string concat?
: > I've also seen to speed the last one up:
: >
: > with Response
: > .Write "this "
: > .Write "that "
: > .Write "this and that"
: > end with
: >
: Chris Hohmann (I think) posted the definitive analysis on this some time
: ago. I don't have tome to go looking for it now, but maybe he'll pop in.
: Regarding the With...End With, reducing the dots that need to be resolved
: will speed things up, but
: 1. In vbscript, it's unlikely to be very noticeable
: 2. there is a threshold before which no performance enhancement will be
: seen. I've seen 5 dot eliminations as the threshold but I really don't
think
: this has been nailed down by anyone.

Are you saying without at least 5 statements, using with won't be a benefit,
re: threshold?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 22 '05 #5
Roland Hall wrote:
"Bob Barrows [MVP]" wrote in message
news:up******** ******@tk2msftn gp13.phx.gbl...
No info on the string concat?

That's what I was referring to here:
*************** *************** ***************
Chris Hohmann (I think) posted the definitive analysis on this some
time ago. I don't have tome to go looking for it now, but maybe
he'll pop in. *************** *************** ***************

Regarding the With...End With, reducing the dots that
need to be resolved will speed things up, but
1. In vbscript, it's unlikely to be very noticeable
2. there is a threshold before which no performance enhancement will
be seen. I've seen 5 dot eliminations as the threshold but I really
don't think this has been nailed down by anyone.


Are you saying without at least 5 statements, using with won't be a
benefit, re: threshold?

No, I meant without at least 5 dot-resolutions. There can be more than one
resolution per line, as in:

With document.all.ta bles(0).rows(0)
.style.backgrou ndcolor="silver "
.style.color="r ed"
end with

This avoids 3 dot-resolutions per line, so the threshold is passed. Again,
in vbscript, the difference will be negligible.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #6
"Bob Barrows [MVP]" wrote in message
news:uY******** *****@TK2MSFTNG P12.phx.gbl...
: Roland Hall wrote:
: > "Bob Barrows [MVP]" wrote in message
: > news:up******** ******@tk2msftn gp13.phx.gbl...
: >
: >
: > No info on the string concat?
: >
: That's what I was referring to here:
: *************** *************** ***************
: >> Chris Hohmann (I think) posted the definitive analysis on this some
: >> time ago. I don't have tome to go looking for it now, but maybe
: >> he'll pop in.
: *************** *************** ***************

Thanks for clearing that up.

: >> Regarding the With...End With, reducing the dots that
: >> need to be resolved will speed things up, but
: >> 1. In vbscript, it's unlikely to be very noticeable
: >> 2. there is a threshold before which no performance enhancement will
: >> be seen. I've seen 5 dot eliminations as the threshold but I really
: >> don't think this has been nailed down by anyone.
: >
: > Are you saying without at least 5 statements, using with won't be a
: > benefit, re: threshold?
: >
: No, I meant without at least 5 dot-resolutions. There can be more than one
: resolution per line, as in:
:
: With document.all.ta bles(0).rows(0)
: .style.backgrou ndcolor="silver "
: .style.color="r ed"
: end with
:
: This avoids 3 dot-resolutions per line, so the threshold is passed. Again,
: in vbscript, the difference will be negligible.

And that...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Jul 22 '05 #7
Roland Hall wrote:
Is this better?

dim str
str = str & "this "
str = str & "that "
str = str & "this and that"
Response.Write str

or this?

dim str
Response.Write "this "
Response.Write "that "
Response.Write "this and that"


Seriously, I believe the second offers better performance. You could easily
test this with a large array or recordset. I tested it in JScript by reading
a SQL table of 5780 quotes totalling 357,886 bytes, or roughly 62 characters
each. To simplify testing, I dumped them into a simple JScript array and
timed the following on some old hardware, on IIS 4/5/6 and with buffering
on/off:

1. for (var i=0; i<a.length; i++) Response.Write( a[i])
2. for (var i=0; i<a.length; i++) str += a[i]; Response.Write( str)
3. Response.Write( a.join(""))

Average results (10 passes):

//--- Dual XEON 550, 768MB RAM, Windows NT Server 4.0 ---//
Case Response.Buffer = true Response.Buffer = false
1. 172ms 390ms
2. 35365ms 35146ms
3. 78ms 109ms

//--- Single XEON 550, 1GB RAM, Windows 2000 Server ---//
Case Response.Buffer = true Response.Buffer = false
1. 141ms 1688ms
2. 29343ms 29177ms
3. 47ms 98ms

//--- Single XEON 550, 1GB RAM, Windows Server 2003 ---//
Case Response.Buffer = true Response.Buffer = false
1. 174ms 500ms
2. 30658ms 30540ms
3. 65ms 73ms
As you can see, concatenation is the biggest hurdle to performance, and
Array.join() beats iteration. The buffering results are self-explanatory,
though I was shocked to see how badly IIS 5 performs with buffering off[1].

I understand that in JScript, Response.Write is late-bound, which accounts
for the big difference between 1 and 3. IIRC, the same test in VBScript
yields a different result altogether. But my memory isn't what it used to
be, so I tested in IIS 6 with buffering on. I found these results[2]:

Case Response.Buffer = true
1. 50ms
2. 16912ms
3. 41ms

Once again, concatenation destroys performance, and Join() still beats
iteration.

On a side note, I compared GetRows() to GetString() for this exercise, and
GetRows() + iteration blew GetString() away. I do not speculate whether this
would be true for a recordset with multiple columns.

[1] Compared to IIS 4 and 6, that is
[2] VBScript cases:
1. For i=0 To UBound(a) : Response.Write( a(i)) : Next
2. For i=0 To UBound(a) : str = str & a(i) : Next : Response.Write( str)
3. Response.Write( Join(a))

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 22 '05 #8
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:up******** ******@tk2msftn gp13.phx.gbl...
Chris Hohmann (I think) posted the definitive analysis on this some time
ago. I don't have tome to go looking for it now, but maybe he'll pop in.

[snip]

I'm not sure how definitive it was, but I think this is the thread you're
talking about:
http://groups-beta.google.com/group/...9c1498e99d805e

And to be fair, Dave Anderson should get equal billing for this thread.
Jul 22 '05 #9
"Dave Anderson" <GT**********@s pammotel.com> wrote in message
news:uv******** ******@TK2MSFTN GP14.phx.gbl...
On a side note, I compared GetRows() to GetString() for this exercise, and
GetRows() + iteration blew GetString() away. I do not speculate whether
this would be true for a recordset with multiple columns.


You can side step the string buffer allocation issue with GetString making
use of the NumRows parameter to output in bursts.
Jul 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
3493
by: Brian Patterson | last post by:
I have noticed in the book of words that hasattr works by calling getattr and raising an exception if no such attribute exists. If I need the value in any case, am I better off using getattr within a try statement myself, or is there some clever implementation enhancement which makes this a bad idea? i.e. should I prefer: if hasattr(self,"datum"): datum=getattr("datum") else: datum=None
12
17309
by: Fred | last post by:
Has anyone a link or any information comparing c and c++ as far as execution speed is concerned? Signal Processing algorithms would be welcome... Thanks Fred
12
8354
by: serge | last post by:
I have an SP that is big, huge, 700-800 lines. I am not an expert but I need to figure out every possible way that I can improve the performance speed of this SP. In the next couple of weeks I will work on preparing SQL statements that will create the tables, insert sample record and run the SP. I would hope people will look at my SP and give me any hints on how I can better write the SP.
6
2324
by: teedilo | last post by:
We have an application with a SQL Server 2000 back end that is fairly database intensive -- lots of fairly frequent queries, inserts, updates -- the gamut. The application does not make use of performance hogs like cursors, but I know there are lots of ways the application could be made more efficient database-wise. The server code is running VB6 of all things, using COM+ database interfaces. There are some clustered and non-clustered...
5
4008
by: Scott | last post by:
I have a customer that had developed an Access97 application to track their business information. The application grew significantly and they used the Upsizing Wizard to move the tables to SQL 2000. Of course there were no modifications made to the queries and they noticed significant performance issues. They recently upgraded the application to Access XP expecting the newer version to provide performance benefits and now queries take...
115
7653
by: Mark Shelor | last post by:
I've encountered a troublesome inconsistency in the C-language Perl extension I've written for CPAN (Digest::SHA). The problem involves the use of a static array within a performance-critical transform function. When compiling under gcc on my big-endian PowerPC (Mac OS X), declaring this array as "static" DECREASES the transform throughput by around 5%. However, declaring it as "static" on gcc/Linux/Intel INCREASES the throughput by...
13
2767
by: bjarne | last post by:
Willy Denoyette wrote; > ... it > was not the intention of StrousTrup to the achieve the level of efficiency > of C when he invented C++, ... Ahmmm. It was my aim to match the performance of C and I achieved that aim very early on. See, for example "The Design and Evolution of C++". -- Bjarne Stroustrup; http://www.research.att.com/~bs
13
4151
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make sense to punch out from managed code to native code (I was using IJW) in order to do some amount of floating point work and, if so, what that certain amount of floating point work was approximately. To attempt to do this I made a program that...
7
2577
by: Michael D. Ober | last post by:
When calling Enqueue, the internal array may need to be reallocated. My question is by how much? In the old MFC array classes, you could tell MFC how many additional elements to add to the array when it needed to reallocate, which greatly boosted performance relative to adding 1 element at a time. Thanks, Mike Ober.
1
2455
by: jvn | last post by:
I am experiencing a particular problem with performance counters. I have created a set of classes, that uses System.Diagnostics.PerformanceCounter to increment custom performance counters (using .Net 2.0) The performance counter categories have been successfully created. When the set of classes are used by a WinForm test harness application, they function as expected, and the performance counters can be seen to be updated by using the...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9037
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.