"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