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 |