• 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
Slow Command in Snow Leopard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Slow Command in Snow Leopard


  • Subject: Slow Command in Snow Leopard
  • From: Luther Fuller <email@hidden>
  • Date: Tue, 06 Apr 2010 15:02:05 -0500

This is a follow-up to yesterday's comments. I was curious just how fast one could count the files in a folder. I hadn't yet tried System Events, so I created a test folder containing 532 files and compiled each of these scripts to an applications with ASE ...

on open dropList
if (count items of dropList) > 1 then return
set folderAlias to (item 1 of dropList) as alias
tell application "Finder" to if (class of item folderAlias) is not folder then return
set elapsedTime to (current date)
--
tell application "System Events"
set folderList to (every disk item of folderAlias whose visible is true)
end tell
--
set elapsedTime to ((current date) - elapsedTime)
set itemCount to (count items of folderList)
"items = " & itemCount & return & "time = " & elapsedTime & " sec"
display dialog the result buttons {"OK"} default button 1
end open

on open dropList
if (count items of dropList) > 1 then return
set folderAlias to (item 1 of dropList) as alias
tell application "Finder" to if (class of item folderAlias) is not folder then return
set elapsedTime to (current date)
--
tell application "Finder"
set folderList to (files of folderAlias)
end tell
--
set elapsedTime to ((current date) - elapsedTime)
set itemCount to (count items of folderList)
"items = " & itemCount & return & "time = " & elapsedTime & " sec"
display dialog the result buttons {"OK"} default button 1
end open

on open dropList
if (count items of dropList) > 1 then return
set folderAlias to (item 1 of dropList) as alias
tell application "Finder" to if (class of item folderAlias) is not folder then return
set elapsedTime to (current date)
--
set folderList to do shell script "ls " & quoted form of (POSIX path of folderAlias)
--
set elapsedTime to ((current date) - elapsedTime)
set AppleScript's text item delimiters to {return}
set itemCount to (count text items of folderList)
"items = " & itemCount & return & "time = " & elapsedTime & " sec"
display dialog the result buttons {"OK"} default button 1
end open


And the results:
ls --------------> about 1 sec
Finder -----------> 10 sec
System Events ----> 26 sec

If you double the size of the test folder, Finder and System Events simply render the system inoperable. You'll have to restart. 'ls' on the other hand seems not to care about the size of the test folder.

 _______________________________________________
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

  • Follow-Ups:
    • Re: Slow Command in Snow Leopard
      • From: Axel Luttgens <email@hidden>
  • Prev by Date: Re: What should be a simple question, I think about creating a file....
  • Next by Date: How come the ip address of system info is wrong?
  • Previous by thread: Slow Command in Snow Leopard
  • Next by thread: Re: Slow Command in Snow Leopard
  • Index(es):
    • Date
    • Thread