On Dec 8, 2006, at 5:28 PM, Kem Tekinay wrote:
On 12/8/06 4:58 PM, Charles Yeomans at [EMAIL PROTECTED] wrote:
Perhaps my English is not so clear; let's try again.
Fast string routines exist right now in REALbasic.
Consider this code. Of the two loops, which would you expect to be
faster?
const kReps = 1000000
dim t1, t2 as double
t1 = microseconds
for i as integer = 1 to kReps
dim s as string = "something"
s = s + " "
s = s + "else"
next
t1 = microseconds - t1
t2 = microseconds
for i as integer = 1 to kReps
static output( 2 ) as string
output = array( "something", " ", "else" )
dim s as string = 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
If you said the second, you would be wrong. The first ran almost
twice as
fast as the second. Even replacing the second loop thusly to avoid the
creation of the array each time does not make it faster than the
first:
Okay. Were you intending this to be a counterexample to my claim?
Charles Yeomans
_______________________________________________
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>