>In conjunction with my SkySVG project, some items that beg the question
>"Which is best?" Meaning, "best" from a speed and efficiency perspective.
>
>1. Accessing character ranges
>
>lsRAh = lsInputLine.char[6..9]
>
>-OR-
>
>lsRAh = chars(lsInputLine, 6, 9)
>
>-OR-
>
>lsRAh = char 6 to 9 of lsInputLine

I haven't done the function test yet, but chars(IsInputLine, 6, 9) seems to 
be fastest in my test.

Here's my code:

on timeTextAccess
   -- member "tx" is a text member with the string
   -- "This is a line of text"

   testText = member("tx").text

   -- create a standardized list of starting positions
   startPos = []
   repeat with i = 1 to 100000
     x=random(21) -- the length of the text - 2
     startPos.append(x)
   end repeat

   startTime = the milliseconds
   repeat with i = 1 to 100000
     firstChar = startPos.getAt(i)
     lastChar = firstChar + 2
     testSubStr = testText.char[firstChar..lastChar]
   end repeat

   loopTime = the milliseconds - startTime
   put "[x..y]: " & loopTime

   startTime = the milliseconds
   repeat with i = 1 to 100000
     firstChar = startPos.getAt(i)
     lastChar = firstChar + 2
     testSubStr = chars(testText,firstChar, lastChar)
   end repeat

   loopTime = the milliseconds - startTime
   put "chars(): " & loopTime

   startTime = the milliseconds
   repeat with i = 1 to 100000
     firstChar = startPos.getAt(i)
     lastChar = firstChar + 2
     testSubStr = char firstChar to lastChar of testText
   end repeat

   loopTime = the milliseconds - startTime
   put "char x to y of z: " & loopTime

end

And the result of 5 runs:

timeTextAccess
-- "[x..y]: 784"
-- "chars(): 568"
-- "char x to y of z: 646"

timeTextAccess
-- "[x..y]: 783"
-- "chars(): 590"
-- "char x to y of z: 648"

timeTextAccess
-- "[x..y]: 803"
-- "chars(): 571"
-- "char x to y of z: 702"

timeTextAccess
-- "[x..y]: 775"
-- "chars(): 572"
-- "char x to y of z: 694"

timeTextAccess
-- "[x..y]: 841"
-- "chars(): 610"
-- "char x to y of z: 665"

I keep coming back to the conclusion that dot syntax is slower. I know that 
there are things you can't do with dot syntax, such as string assignment. 
Are there things you can do with dot syntax you can't do with old notation?

Cordially,

Kerry Thompson

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to