Revert makes 'offset' faster?
Revert makes 'offset' faster?
- Subject: Revert makes 'offset' faster?
- From: Nigel Garvey <email@hidden>
- Date: Sat, 14 Sep 2002 16:04:16 +0100
For the past few months, I've been toying with a superhandler which is
intended as an alternative to the Standard Additions' 'offset' command.
It offers some useful variations and - in its default configuration - is
meant to be faster than 'offset'. It's comfortably so on my 4400 (AS
1.3.7) but it's a closer call on my Pismo(?) PowerBook (AS 1.6), so I've
been trying some speed tweaks. The script I use to compare the speeds is
very conventional:
set str to "Now is the time for all good men to come to the aid of the
party."
set sub to "party"
set lotsa to 500
set t to the ticks
repeat lotsa times
offset of sub in str
end repeat
set t1 to (the ticks) - t
set t to the ticks
repeat lotsa times
fastOffset of sub into str given spec:{}
end repeat
set t2 to (the ticks) - t
{t1, t2}
(The handler here.)
This is saved to disk with each speed improvement to the handler so that
I can come back and tweak it some more later. Currently, when I launch
the 1.6 Script Editor and run the script, the result is typically {61,
53} - that is, my handler takes 8 ticks less than 'offset' to find the
same substring 500 times. Editing the script either affects my handler's
speed or not. :-)
If I then use Script Editor's 'Revert' command to reload the script from
the saved file, the typical result becomes {37, 53} - that is, 'offset'
speeds up considerably. It stays sped up until I quit Script Editor and
relaunch it, whereupon the 'offset' speed returns to about 61.
If I modify the script to display the results, and save it as a classic
application, it displays "{743, 55}" when run by itself and "{35, 51}"
when run in Script Editor.
If I save a script containing just the 'offset' speed test, the result is
about 47-50 ticks for 500 iterations, which speeds up to about 35 ticks
when I 'revert' to it.
Weird, or what? Certainly inconvenient for my purposes.
NG
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.