On 12/8/06 6:55 PM, Tim Hare at [EMAIL PROTECTED] wrote:

> With all due respect, your code actually measures the penalty for dimming
> your variables inside the loop.  Remove the dim statements to the top of the
> program, and the second loop (join) becomes the faster option.  You also pay
> a penalty for using the array("something", " ", "else") line, over setting
> the array elements individually.  This speeds up the second loop even
> further.

I don¹t know if you tested this, but my results are exactly the opposite.
The first version is still faster.

  const kReps = 1000000
  
  dim t1, t2 as double
  
  t1 = microseconds
  dim s as string
  for i as integer = 1 to kReps
    s = "something"
    s = s + " "
    s = s + "else"
  next
  t1 = microseconds - t1
  
  t2 = microseconds
  dim output( 2 ) as string
  for i as integer = 1 to kReps
    output( 0 ) = "something"
    output( 1 ) = " "
    output( 2 ) = "else"
    s = join( output, "" )
  next
  t2 = microseconds - t2
  
  t1 = t1 / 1000000
  t2 = t2 / 1000000
  
  dim tally as string = format( t1, "#,0.000" ) + chr( 13 ) + format( t2,
"#,0.000" )
  MsgBox tally

__________________________________________________________________________
Kem Tekinay                                                 (212) 201-1465
MacTechnologies Consulting                              Fax (914) 242-7294
http://www.mactechnologies.com                        Pager (917) 491-5546

  To join the MacTechnologies Consulting mailing list, send an e-mail to:
           [EMAIL PROTECTED]






_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to