Re: Does VBscript support " & _" for long strings?
- From: "Justin Piper" <jpiper@xxxxxxxxx>
- Date: Thu, 18 Jan 2007 10:08:07 -0600
On Thu, 18 Jan 2007 03:27:44 -0600, Anthony Jones <Ant@xxxxxxxxxxxxxxxx> wrote:
It does depend on the actual application. If you are concatenating a set of
constants as in the OP then the above is a fair comparison, although I
suspect a real world requirement would include more than just 3
concatenations and Join would probably overtake direct concatenation fairly
quickly as the number of constants increased.
Interestingly, this does seem to be the case. With 1000 concatenations, the concatenation operator takes over 200 times longer than Join/Array. I imagine that each use of the concatenation operator is creating temporary values and then throwing them away after appending the next value.
If you are concatenating a set of strings retrieved from a function or
expression such as from a field value you would assign each element directly
to an array element. Hence the use of the Array function above adds an
extra copy of each string that would not be present in a real solution..
Assigning a large string to an element in an array apparently is slightly faster than creating the same array using the Array function, but not so much that Array could be making superfluous copies of the string.
Option Explicit
Dim a: a = String(100000000, "a")
Function Prof(f)
Dim start, finish, i, total
total = 0
For i = 0 To 9
start = Timer()
f
finish = Timer()
total = total + finish - start
Next
Prof = total/10
End Function
Sub ProfDim()
Dim aa(0): aa(0) = a
End Sub
WScript.Echo "Dim" & vbTab & Prof(GetRef("ProfDim")) & "s"
Sub ProfArray()
Dim aa: aa = Array(a)
End Sub
WScript.Echo "Array" & vbTab & Prof(GetRef("ProfArray")) & "s"
--
Justin Piper
Bizco Technologies
http://www.bizco.com/
.
- Follow-Ups:
- Re: Does VBscript support " & _" for long strings?
- From: Anthony Jones
- Re: Does VBscript support " & _" for long strings?
- References:
- Does VBscript support " & _" for long strings?
- From: Ed
- Re: Does VBscript support " & _" for long strings?
- From: Michael Harris \(MVP\)
- Re: Does VBscript support " & _" for long strings?
- From: Ed
- Re: Does VBscript support " & _" for long strings?
- From: Alexander Mueller
- Re: Does VBscript support " & _" for long strings?
- From: Ed
- Re: Does VBscript support " & _" for long strings?
- From: mayayana
- Re: Does VBscript support " & _" for long strings?
- From: Ed
- Re: Does VBscript support " & _" for long strings?
- From: Bob Barrows [MVP]
- Re: Does VBscript support " & _" for long strings?
- From: Ed
- Re: Does VBscript support " & _" for long strings?
- From: Bob Barrows [MVP]
- Re: Does VBscript support " & _" for long strings?
- From: Justin Piper
- Re: Does VBscript support " & _" for long strings?
- From: Bob Barrows [MVP]
- Re: Does VBscript support " & _" for long strings?
- From: Justin Piper
- Re: Does VBscript support " & _" for long strings?
- From: Anthony Jones
- Does VBscript support " & _" for long strings?
- Prev by Date: Re: Cross-Forest - IADsGroup::Add receiving error 80072030 "There is no such object on the server"
- Next by Date: Changing file to uppercase
- Previous by thread: Re: Does VBscript support " & _" for long strings?
- Next by thread: Re: Does VBscript support " & _" for long strings?
- Index(es):
Relevant Pages
|