Interesting.  Yes, I did test it, and once I moved the dim statements, I
couldn't get the second loop to be slower no matter what esoteric thing I
did in the second loop.  It always won.

This was on Windows XP.

I realize this is all anecdotal.

Tim


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Kem
> Tekinay
> Sent: Friday, December 08, 2006 10:10 PM
> To: REALbasic-NUG
> Subject: Re: The perl challenge
>
>
> 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]
>
>
>
>
>
>
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.432 / Virus Database: 268.15.15/580 - Release Date:
> 12/8/2006 12:53 PM
>
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.15.15/580 - Release Date: 12/8/2006
12:53 PM

_______________________________________________
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