Re: processing time & stack overflow
Re: processing time & stack overflow
- Subject: Re: processing time & stack overflow
- From: Victor Yee <email@hidden>
- Date: Wed, 29 Aug 2001 11:44:58 -0400
With more time to play, I was able to write a coherent and tested script. It uses Tex-Edit Plus, but could be easiliy modified to use another scriptable text editor. The script as an applet doesn't require much memory; as long as the text editor has enough to open the file, it should be fine.
Did some time tests and this script seems to be a pretty decent mix of speed and scalability. Here's one set of results OMM:
00:01:45 for about 1,000 words
00:04:00 for about 2,000 words
00:12:13 for about 5,000 words
It seems that the processing time scales in a predictable manner. Probably about 25 to 30 minutes for 10,000 words.
I tried a similar script using Tim's randomizing code and the speed difference wasn't much (but Arthur's still won).
Hope this makes up for some of my rambling in this thread.
By the way, monk, what's a "cross-cutting" script used for?
Victor
-- start
set sourceFile to (choose file with prompt "choose source to juxtapose:")
set numberOfFiles to "1"
repeat until class of numberOfFiles is integer and numberOfFiles > 0 and numberOfFiles < 100
try
display dialog "enter amount of files to generate from source (1-99)?" default answer numberOfFiles giving up after 12
set numberOfFiles to text returned of the result as integer
on error
display dialog "that wasn't the right kind of number!"
end try
end repeat
set folderName to "juxtatext(s)"
tell application "Finder"
if not (exists folder folderName of desktop) then
make new folder at desktop with properties {name:folderName}
end if
set juxtaFolder to (folder folderName of desktop) as string
end tell
set startTime to (current date)
tell application "Tex-Edit Plus"
activate
open sourceFile
set wordCount to count of words of window 1
end tell
repeat with x from 1 to numberOfFiles
set {s1, s2} to {random number from 1 to wordCount, 31415}
repeat with a from 1 to wordCount
set b to s1 mod wordCount + 1
set s1 to (s1 * s2) mod wordCount
tell window 1 of application "Tex-Edit Plus"
set thisWord to text of word a
set contents of word a to text of word b
set contents of word b to thisWord
end tell
end repeat
set filePath to "" & juxtaFolder & "juxtatext " & characters -2 thru -1 of ("0" & x)
tell window 1 of application "Tex-Edit Plus"
save in file filePath
end tell
end repeat
set endTime to (current date)
set totalTime to endTime - startTime
activate
display dialog "Total processing time: " & ,
text -2 thru -1 of ("0" & (totalTime div 3600)) ,
& ":" & text -2 thru -1 of ("0" & (totalTime mod 3600) div 60) ,
& ":" & text -2 thru -1 of ("0" & totalTime mod 60)
-- end