• 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
read a file - Lion vrs Tiger
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

read a file - Lion vrs Tiger


  • Subject: read a file - Lion vrs Tiger
  • From: Jim Brandt <email@hidden>
  • Date: Wed, 26 Sep 2012 12:26:51 -0500

I have a question about reading files in Lion vrs Tiger.

I have a script that is running very sluggishly under Lion on a Mac Mini. This same script ran much faster under Tiger, so I've been trying to figure out why.

The script is very long and involved so I'm breaking the testing up into pieces. The first thing it does is read several HTML files and strip out rows of a table from each file. Each HTML page is between 6 and 7 K in size.

So I timed this piece of the script.

Here's the main part of this piece of the script:

set theList to FileLib's GetFileListOfFolder(HTMLFolder, false) -- get files in HTML folder

set RowSearchStr to "<td class=\"lc1\">.*?</tr>"
set TitleSearchStr to "<title>.*?</title>"
set AllRows to {}
tell application "TextCommands" to set startTime to lowercase (time string of (current date))

repeat with eachFile in theList
   tell application "Finder" to set nm to name of eachFile
   tell application "Finder" to set knd to kind of eachFile as text 
   if not (nm begins with " ") then -- skip files beginning with a space
      if (knd is "Document") or (knd is "HTML document") then
         set fileCnt to fileCnt + 1
         set theFile to eachFile as alias
         -- read the file
         set FileRef to open for access theFile
         set DocumentText to read FileRef
         close access FileRef

         

         tell application "TextCommands" to set Rows to search DocumentText for RowSearchStr with regex
         set AllRows to AllRows & Rows -- append
      end if
   end if
end repeat

tell application "TextCommands" to set StopTime to lowercase (time string of (current date)) -- debug

set totalCnt to count of AllRows
set mess to "Start: " & startTime & return & "Stop: " & StopTime & return & return -- debug
set mess to mess & "Possible files: " & (totalCnt as text) & " found in " & (fileCnt as text) & " files." -- debug
display dialog mess with title appTitle -- debug

When run this on the Mac Mini under Lion I get:

Start: 12:04:39 pm
Stop: 12:05:05 pm

Possible files: 686 found in 69 files.

When I run it on a Dual 450 G4 running Tiger I get:

Start: 12:09:03 pm
Stop: 12:03:08 pm

Possible files: 686 found in 69 files.

only 5 seconds under Tiger but under Lion it's taking 26 seconds.

Can anyone shed some light on this?

Is there a better way to read a text file than the read command?

I still have other issues but this is step one.

TIA,

Jim Brandt
 _______________________________________________
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: read a file - Lion vrs Tiger
      • From: Shane Stanley <email@hidden>
    • Re: read a file - Lion vrs Tiger
      • From: "koenig.yvan" <email@hidden>
    • Re: read a file - Lion vrs Tiger
      • From: Jörgen Stahle <email@hidden>
  • Prev by Date: Re: Mail: save attachment fails in Mountain Lion 10.8.2
  • Next by Date: Re: read a file - Lion vrs Tiger
  • Previous by thread: Entourage to Outlook snafu
  • Next by thread: Re: read a file - Lion vrs Tiger
  • Index(es):
    • Date
    • Thread