• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Why is my code so slow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is my code so slow


  • Subject: Re: Why is my code so slow
  • From: Brian Christmas <email@hidden>
  • Date: Sat, 29 Nov 2014 17:47:06 +1100

David, this version will give you how many loops occur, with 100 extra characters, in one second. I get something similar to Shanes speed, about 1600 loops. Let us know your speed if you like.

Regards

Santa

set s to "              test                                             "
set timeStarted to current date
repeat while (current date) - timeStarted = 0
end repeat
set timeStarted to current date
set x to 0
repeat 10000 times
set x to x + 1
set answerLoops to my Trim(s)
if (current date) - timeStarted = 1 then exit repeat
end repeat
say x & " loops in a second, with " & ((count of s) - 4) & " extra characters" as text

on Trim(s)
-- Find first non-white character
set i to 1
repeat
try
if character i of s ≠ " " and character i of s ≠ " " then
exit repeat
end if
on error
exit repeat
end try
set i to i + 1
end repeat


set j to length of s
repeat
try
if (character j of s ≠ " " and character j of s ≠ " ") or j ≤ i then
exit repeat
end if
on error
exit repeat
end try
set j to j - 1
end repeat
return (text i through j of s)
end Trim

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Why is my code so slow (From: Brian Christmas <email@hidden>)

  • Prev by Date: Re: Why is my code so slow
  • Next by Date: Re: How do I set folder action in Yosemite, please?
  • Previous by thread: Re: Why is my code so slow
  • Next by thread: Re: Why is my code so slow
  • Index(es):
    • Date
    • Thread