473,804 Members | 3,932 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
31 2245
Chris Hohmann wrote:
You can side step the string buffer allocation issue with GetString
making use of the NumRows parameter to output in bursts.


Which I didn't get into, since I had already strayed well beyond the bounds
of the original question. And also because this would require me to explore
the issue of optimal block size.

The whole tradeoff between overhead and improved efficiency is quite
fascinating to me. To illustrate the problem, consider the problem of
factoring integers. Trial division is really efficient for factoring small
integers. At some point -- let's say at 5 digits -- Pollard's P-1 (or
perhaps Rho) algorithm becomes efficient enough to compensate for its
additional overhead, and is faster on average than trial division. At 40 or
50 digits, the elliptic curves algorithm starts to reign -- at least until
it reaches Quadratic Seive/GNFS territory.

This problem has a likely analogy. If we need to dump 10 rows out of a
database, it would be silly to do bursts of GetString. No doubt there is an
upper threshold above which some other technique would be optimal. So what
are we supposed to do?

In practice we rarely need to answer that question. Most web requests are
intended for an audience that cannot digest hundreds (much less hundreds of
thousands) of rows per response. In my opinion, your design is suspect long
before you reach the conclusion that you should break up your GetString call
into a bunch of smaller ones.
--
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 #11
"Dave Anderson" <GT**********@s pammotel.com> wrote in message
news:uP******** ******@TK2MSFTN GP12.phx.gbl...
Chris Hohmann wrote:
You can side step the string buffer allocation issue with GetString
making use of the NumRows parameter to output in bursts.


Which I didn't get into, since I had already strayed well beyond the
bounds of the original question. And also because this would require me to
explore the issue of optimal block size.

The whole tradeoff between overhead and improved efficiency is quite
fascinating to me. To illustrate the problem, consider the problem of
factoring integers. Trial division is really efficient for factoring small
integers. At some point -- let's say at 5 digits -- Pollard's P-1 (or
perhaps Rho) algorithm becomes efficient enough to compensate for its
additional overhead, and is faster on average than trial division. At 40
or 50 digits, the elliptic curves algorithm starts to reign -- at least
until it reaches Quadratic Seive/GNFS territory.

This problem has a likely analogy. If we need to dump 10 rows out of a
database, it would be silly to do bursts of GetString. No doubt there is
an upper threshold above which some other technique would be optimal. So
what are we supposed to do?

In practice we rarely need to answer that question. Most web requests are
intended for an audience that cannot digest hundreds (much less hundreds
of thousands) of rows per response. In my opinion, your design is suspect
long before you reach the conclusion that you should break up your
GetString call into a bunch of smaller ones.


Agreed. I simply wanted to comapre aples to apples. GetString + iteration
will outperform GetRows + iteration in this scenario.
Jul 22 '05 #12
"Chris Hohmann" wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
: "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.

Thanks Chris. And to give equal billing, sending a duplicate bill to Dave.
Terms: Net 7 Please pay on time to avoid late charges.

--
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 #13
"Dave Anderson" wrote in message
news:uv******** ******@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"
:
: 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

That's a noticeable difference between NT and 2K on #1.

: //--- Single XEON 550, 1GB RAM, Windows Server 2003 ---//
: Case Response.Buffer = true Response.Buffer = false
: 1. 174ms 500ms
: 2. 30658ms 30540ms
: 3. 65ms 73ms

And not much difference between all on #3 even though 2K and 2K3 have
additional RAM.

: 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 guess you didn't happen to test with flushing [the data] ever so often
when buffering?!

: 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.

That's interesting. How can I take adavantage of getRows with iteration
where I want cosmetic differences in the results. A simple example of every
other row with a different background color.

: [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))

--
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 #14
"Chris Hohmann" wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
: "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.

You saying, in that thread that this:

dim arr
arr = Array("A","B"," C")

is significantly better than...

dim arr
arr = split("A,B,C"," ,")

Where is the threshold where it becomes noticeable?

--
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 #15
Roland Hall wrote:
I guess you didn't happen to test with flushing [the data] ever so
often when buffering?!


No, because that just leads to more analysis. What if you flush the buffer
after every write? How about after every Nth write? Tedious.
On a side note, I compared GetRows() to GetString() for this
exercise, and GetRows() + iteration blew GetString() away...

That's interesting. How can I take adavantage of getRows with
iteration where I want cosmetic differences in the results. A simple
example of every other row with a different background color.


You may be confusing GetRows() with GetString(). GetRows() dumps the
recordset into a 2D array. Since you are presumably traversing that array
row-by-row already, it should be trivial to implement your cosmetic
variations.
--
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 #16
Roland Hall wrote:
You saying, in that thread that this:

dim arr
arr = Array("A","B"," C")

is significantly better than...

dim arr
arr = split("A,B,C"," ,")

Where is the threshold where it becomes noticeable?


This is not an ASP question.

--
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 #17
"Dave Anderson" wrote in message
news:ei******** ******@TK2MSFTN GP12.phx.gbl...
: Roland Hall wrote:
: > I guess you didn't happen to test with flushing [the data] ever so
: > often when buffering?!
:
: No, because that just leads to more analysis. What if you flush the buffer
: after every write? How about after every Nth write? Tedious.

My goodness Dave. Obviously I'm not wanting to double processing in hopes
of decreasing latency. However, perhaps there is a potential for an
increase in performance by flusing the buffer every now and then. Saying
it's not worth considering because it requires more analysis dosen't seem
like a worthwhile response.

: >> On a side note, I compared GetRows() to GetString() for this
: >> exercise, and GetRows() + iteration blew GetString() away...
: > That's interesting. How can I take adavantage of getRows with
: > iteration where I want cosmetic differences in the results. A simple
: > example of every other row with a different background color.
:
: You may be confusing GetRows() with GetString(). GetRows() dumps the
: recordset into a 2D array. Since you are presumably traversing that array
: row-by-row already, it should be trivial to implement your cosmetic
: variations.

If is use getrows and want every other background a different color, I have
use a MOD or something to determine which will have a negative impact on the
advantage of using getrows. At this point getstring seems to have a
disadvantage since it uses markup as parameters. There is nothing that
says, use all even or all odd rows with different markup.

If the comparison is only for a drab layout, then it's not that realistic
except perhaps to an accountant. I'm still using For...Next loops, which
will require a decision to determine which row is which unless you use
alternating loops separating odd and even and that seems to be bad
alternative.

--
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 #18
"Dave Anderson" wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
: Roland Hall wrote:
: > You saying, in that thread that this:
: >
: > dim arr
: > arr = Array("A","B"," C")
: >
: > is significantly better than...
: >
: > dim arr
: > arr = split("A,B,C"," ,")
: >
: > Where is the threshold where it becomes noticeable?
:
: This is not an ASP question.

It's being used on a web page with a .asp extension between <% and %>. What
would you label it?

--
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 #19
Roland Hall wrote:

If is use getrows and want every other background a different color,
I have use a MOD or something to determine which will have a negative
impact on the advantage of using getrows.
But it still beats the alternative of looping through your recordset.
At this point getstring
seems to have a disadvantage since it uses markup as parameters.
There is nothing that says, use all even or all odd rows with
different markup.

If the comparison is only for a drab layout, then it's not that
realistic except perhaps to an accountant. I'm still using
For...Next loops, which will require a decision to determine which
row is which unless you use alternating loops separating odd and even
and that seems to be bad alternative.

Or you could incorporate some of that logic into the query that produces the
resultset.
Perhaps a computed column that indicates the color to be used for a row ...

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 22 '05 #20

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

Similar topics

25
3497
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
17311
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
4009
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
7662
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
2770
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
4152
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
2581
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
2459
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
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10577
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10332
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
7620
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
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5521
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...
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
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.