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

Re: ASP Performance by Dave

Dave
Mon Apr 04 15:54:19 CDT 2005

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.



Re: ASP Performance by Roland

Roland
Mon Apr 04 16:09:00 CDT 2005

"Dave Anderson" wrote in message
news:ecOZ9hVOFHA.2132@TK2MSFTNGP14.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



Re: ASP Performance by Bob

Bob
Tue Apr 05 07:24:06 CDT 2005

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.



Re: ASP Performance by Roland

Roland
Tue Apr 05 16:39:46 CDT 2005

"Bob Barrows [MVP]" wrote in message
news:upz1dpdOFHA.3788@tk2msftngp13.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



Re: ASP Performance by Bob

Bob
Tue Apr 05 17:00:42 CDT 2005

Roland Hall wrote:
> "Bob Barrows [MVP]" wrote in message
> news:upz1dpdOFHA.3788@tk2msftngp13.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.tables(0).rows(0)
.style.backgroundcolor="silver"
.style.color="red"
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.



Re: ASP Performance by Roland

Roland
Tue Apr 05 17:34:55 CDT 2005

"Bob Barrows [MVP]" wrote in message
news:uYr9oriOFHA.508@TK2MSFTNGP12.phx.gbl...
: Roland Hall wrote:
: > "Bob Barrows [MVP]" wrote in message
: > news:upz1dpdOFHA.3788@tk2msftngp13.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.tables(0).rows(0)
: .style.backgroundcolor="silver"
: .style.color="red"
: 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. */



Re: ASP Performance by Dave

Dave
Wed Apr 06 12:03:42 CDT 2005

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.



Re: ASP Performance by Chris

Chris
Wed Apr 06 14:11:17 CDT 2005

"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:upz1dpdOFHA.3788@tk2msftngp13.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/microsoft.public.inetserver.asp.general/browse_frm/thread/8804807f08dc4c88/c89c1498e99d805e

And to be fair, Dave Anderson should get equal billing for this thread.



Re: ASP Performance by Chris

Chris
Wed Apr 06 14:18:31 CDT 2005

"Dave Anderson" <GTSPXOESSGOQ@spammotel.com> wrote in message
news:uvzfYqsOFHA.3716@TK2MSFTNGP14.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.



Re: ASP Performance by Dave

Dave
Wed Apr 06 16:13:22 CDT 2005

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.



Re: ASP Performance by Chris

Chris
Wed Apr 06 17:12:27 CDT 2005

"Dave Anderson" <GTSPXOESSGOQ@spammotel.com> wrote in message
news:uPeG51uOFHA.4052@TK2MSFTNGP12.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.



Re: ASP Performance by Roland

Roland
Wed Apr 06 22:58:46 CDT 2005

"Chris Hohmann" wrote in message
news:%23Qn8yytOFHA.3892@TK2MSFTNGP10.phx.gbl...
: "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
: news:upz1dpdOFHA.3788@tk2msftngp13.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/microsoft.public.inetserver.asp.general/browse_frm/thread/8804807f08dc4c88/c89c1498e99d805e
:
: 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



Re: ASP Performance by Roland

Roland
Wed Apr 06 23:09:58 CDT 2005

"Dave Anderson" wrote in message
news:uvzfYqsOFHA.3716@TK2MSFTNGP14.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



Re: ASP Performance by Roland

Roland
Wed Apr 06 23:16:17 CDT 2005

"Chris Hohmann" wrote in message
news:%23Qn8yytOFHA.3892@TK2MSFTNGP10.phx.gbl...
: "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
: news:upz1dpdOFHA.3788@tk2msftngp13.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/microsoft.public.inetserver.asp.general/browse_frm/thread/8804807f08dc4c88/c89c1498e99d805e
:
: 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



Re: ASP Performance by Dave

Dave
Fri Apr 08 09:00:55 CDT 2005

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.




Re: ASP Performance by Dave

Dave
Fri Apr 08 09:04:28 CDT 2005

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.



Re: ASP Performance by Roland

Roland
Fri Apr 08 19:44:04 CDT 2005

"Dave Anderson" wrote in message
news:eiD2jNEPFHA.1172@TK2MSFTNGP12.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



Re: ASP Performance by Roland

Roland
Sat Apr 09 01:04:56 CDT 2005

"Dave Anderson" wrote in message
news:%235HYiPEPFHA.2144@TK2MSFTNGP09.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



Re: ASP Performance by Bob

Bob
Sat Apr 09 07:15:47 CDT 2005

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"



Re: ASP Performance by dlbjr

dlbjr
Sat Apr 09 08:25:14 CDT 2005

Why not use something like the code below to set row style:
No Mod Check or any heavy processing code needed.

Function GetRowStyle(str1)

Select Case str1
Case "Style1"
GetRowStyle = "Style2"
Case Else
GetRowStyle = "Style1"
End Select
End Function


PS. The Getrows() is the way to go with the data.

'dlbjr
'Pleading sagacious indoctrination!



Re: ASP Performance by Dave

Dave
Sat Apr 09 17:13:46 CDT 2005

"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?

VBScript, obviously.


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



Re: ASP Performance by Dave

Dave
Sat Apr 09 17:32:03 CDT 2005

"Roland Hall" wrote:
>> 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.

By "tedious", I was referring to doing more analysis. You asked if I
happened to do that analysis, and my answer was: "No, because that would
require a lot more than a single simple observation."

I don't really see what your beef is.



>>> ...How can I take adavantage of getRows with iteration where I want
>>> cosmetic differences in the results...
>
> ...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.

It seems you already know the answer to your question.


> ...I'm still using For...Next loops, which will require a decision to
> determine which row is which...

Does it really? Here's an alternative with no "decision":

<style>
tr.row0 { background-color:#fff }
tr.row1 { background-color:#eee }
</style>
<% for (i=0; i<ary.length; i++) { %>
<tr class="row<%=i%2%>"> ...

Here's another:

<% var colors=["#fff","#eee"]
for (i=0; i<ary.length; i++) { %>
<tr stlye="background-color:<%=colors[i%2]%>"> ...


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



Re: ASP Performance by dlbjr

dlbjr
Sat Apr 09 18:31:07 CDT 2005

It is best to use tags as such in asp:

<script language="VBScript" runat="Server">

</script>

<script language="javascript" runat="Server">

</script>

This allows a mixed use (if needed) of multiple languages on as single page.
No dependency on the Default Language setting in IIS.
Assuming the server is set to VBScript is a false assumption.
Moving pages from one server to another can fail.

Using Tags as such:

<% %>

Assumes the default language is set to what you are using.
You should at least clarify the language at the top of the asp.

'dlbjr
'Pleading sagacious indoctrination!



Re: ASP Performance by Roland

Roland
Sun Apr 10 15:11:16 CDT 2005

"Bob Barrows [MVP]" wrote in message
news:%23A0Ya3PPFHA.1096@tk2msftngp13.phx.gbl...
: 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.

Yes, I would agree. I read a document that says getrows sometimes,
getstring sometimes AND recordset loops sometimes but not sure where I read
it. It was either aspfaqs.com or 4guysfromrolla.com, which I think is run
by the same people.

Would you agree that recordset loops can be used sometimes?

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

A computer column that returns a hex value?

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



Re: ASP Performance by Roland

Roland
Sun Apr 10 15:14:21 CDT 2005

"dlbjr" wrote in message news:OkZZReQPFHA.2468@tk2msftngp13.phx.gbl...
: Why not use something like the code below to set row style:
: No Mod Check or any heavy processing code needed.

But it's still a decision tree, is it not? Does SELECT...CASE perform
better than IF...THEN?

: Function GetRowStyle(str1)
:
: Select Case str1
: Case "Style1"
: GetRowStyle = "Style2"
: Case Else
: GetRowStyle = "Style1"
: End Select
: End Function
:
:
: PS. The Getrows() is the way to go with the data.

As a primary or a constant solution? I'm trying to narrow down and document
what will perform best for a given situation.

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



Re: ASP Performance by Roland

Roland
Sun Apr 10 15:24:17 CDT 2005

"Dave Anderson" wrote in message news:115glvdlfnqu5e1@corp.supernews.com...
: "Roland Hall" wrote:
: >> 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.
:
: By "tedious", I was referring to doing more analysis. You asked if I
: happened to do that analysis, and my answer was: "No, because that would
: require a lot more than a single simple observation."
:
: I don't really see what your beef is.

I'm trying to draw knowledge from the well and you're telling me it's too
hard to bring the bucket to the top. (O:=

: >>> ...How can I take adavantage of getRows with iteration where I want
: >>> cosmetic differences in the results...
: >
: > ...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.
:
: It seems you already know the answer to your question.

It shouldn't because I don't. I'm posing these questions to gain knowledge
because I may not have considered some variables and there are people here a
lot better at this than I am.

: > ...I'm still using For...Next loops, which will require a decision to
: > determine which row is which...
:
: Does it really? Here's an alternative with no "decision":
:
: <style>
: tr.row0 { background-color:#fff }
: tr.row1 { background-color:#eee }
: </style>
: <% for (i=0; i<ary.length; i++) { %>
: <tr class="row<%=i%2%>"> ...
:
: Here's another:
:
: <% var colors=["#fff","#eee"]
: for (i=0; i<ary.length; i++) { %>
: <tr stlye="background-color:<%=colors[i%2]%>"> ...

Ok, that's helpful. Thank you.

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



Re: ASP Performance by Bob

Bob
Sun Apr 10 15:48:41 CDT 2005

Roland Hall wrote:
> "Bob Barrows [MVP]" wrote in message
> news:%23A0Ya3PPFHA.1096@tk2msftngp13.phx.gbl...
>> 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.
>
> Yes, I would agree. I read a document that says getrows sometimes,
> getstring sometimes AND recordset loops sometimes but not sure where
> I read it. It was either aspfaqs.com or 4guysfromrolla.com, which I
> think is run by the same people.

It was this article on aspfaq:
http://www.aspfaq.com/show.asp?id=2467

>
> Would you agree that recordset loops can be used sometimes?
>

Yes, for things like subtotals, grouping, etc. But always disconnect them
first.

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

Right

>>>
>>> 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 ...
>
> A computer column that returns a hex value?

Sure, why not? or a color in plain English. Or a flag to be read by your
loop. Of course, your data source has to be set up so that this logic can be
applied by the sql statement.

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"



Re: ASP Performance by dlbjr

dlbjr
Sun Apr 10 22:35:56 CDT 2005

Yes! A SELECT...CASE will perform far better than IF...THEN
Constant! I use GetRows() exclusively when looping through data.

'dlbjr
'Pleading sagacious indoctrination!



Re: ASP Performance by Roland

Roland
Mon Apr 11 07:01:03 CDT 2005

"Bob Barrows [MVP]" wrote in message
news:%23l3Ep6gPFHA.3716@TK2MSFTNGP14.phx.gbl...
: Roland Hall wrote:
: > "Bob Barrows [MVP]" wrote in message
: > news:%23A0Ya3PPFHA.1096@tk2msftngp13.phx.gbl...
: >> 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.
: >
: > Yes, I would agree. I read a document that says getrows sometimes,
: > getstring sometimes AND recordset loops sometimes but not sure where
: > I read it. It was either aspfaqs.com or 4guysfromrolla.com, which I
: > think is run by the same people.
:
: It was this article on aspfaq:
: http://www.aspfaq.com/show.asp?id=2467

That may be the one.

: > A computer column that returns a hex value?
:
: Sure, why not? or a color in plain English. Or a flag to be read by your
: loop. Of course, your data source has to be set up so that this logic can
be
: applied by the sql statement.

I was only verifying. A different approach than I have used. I'm sure I'll
find all kinds of performance gains if I spend more time on SPs and looking
at SQL alternatives.

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



Re: ASP Performance by Dave

Dave
Mon Apr 11 08:24:47 CDT 2005

Roland Hall wrote:
>> It seems you already know the answer to your question.
>
> It shouldn't because I don't. I'm posing these questions to gain
> knowledge because I may not have considered some variables and there
> are people here a lot better at this than I am.

Your question: "How can I take adavantage of getRows with iteration
where I want cosmetic differences in the results?"

Your answer: "If is use getrows and want every other background a
different color, I have use a MOD or something..."

As I said, you already know the answer to your question. If you are
iterating through the array produced by GetRows(), you can use (rownum Mod
2). What more were you expecting?



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



Re: ASP Performance by Roland

Roland
Mon Apr 11 16:24:33 CDT 2005

"Dave Anderson" wrote in message
news:eWKVWnpPFHA.648@TK2MSFTNGP14.phx.gbl...
: Roland Hall wrote:
: >> It seems you already know the answer to your question.
: >
: > It shouldn't because I don't. I'm posing these questions to gain
: > knowledge because I may not have considered some variables and there
: > are people here a lot better at this than I am.
:
: Your question: "How can I take adavantage of getRows with iteration
: where I want cosmetic differences in the results?"
:
: Your answer: "If is use getrows and want every other background a
: different color, I have use a MOD or something..."
:
: As I said, you already know the answer to your question. If you are
: iterating through the array produced by GetRows(), you can use (rownum Mod
: 2). What more were you expecting?

I wasn't doing it as you were with a dynamic class name. I had a
conditional in the middle of it. Your method eliminates the conditional and
removes the performance