Re: Longer and longer...
Re: Longer and longer...
- Subject: Re: Longer and longer...
- From: Gil Dawson <email@hidden>
- Date: Thu, 9 Sep 2010 11:30:12 -0700
Thanks for your suggestions! Sorry it took me so long to get back to you, but I was called away to another project.
To review: I have a long-running script which I recompile and run over and over. Each time it runs slower, until I quit and relaunch AppleScript Editor. Smile does not do this, only Script Editor.
> Try clearing your variables in your init routines.
> May you check if you are using some properties ?
I forgot to mention in my original post that the script is recompiled each time I run it. I believe that recompiling will clear all variables and reset properties, n'est pas?
> open Activity monitor and […see whether…] your script is using more and more memory as you go.
I did this, using a slightly reduced copy of my script, making a nugatory change (e.g., adding a space to the end of a line) and Saving to force a recompile each time, and got the following results:
Using MacOS 10.4.6...
With AppleScript Editor (Version 2.3 (118)):
Loop Run Real Mem
Run# Time Time at End
1. 32ms 38s 98.5Mb
2. 48ms 104s 147.6Mb
3. 69ms 156s 211.8Mb
4. 85ms 220s 258.6Mb
<At this point, I Quit and Relaunched AppleScript Editor>
5. 31ms 70s 109.5Mb
6. 56ms 130s 165.2Mb
With Smile (Version 3.5.3):
1. 30ms 41s 38.1Mb
2. 30ms 41s 40.3Mb
3. 28ms 40s 40.8Mb
See the difference?
I think that what I'm seeing is a memory leak or something like that in AppleScript Editor.
I submitted Apple Bug ID# 8411740, however, I can't imagine Apple fixing AppleScript Editor to remove this effect in the near term because it's not a big bother to most people.
I mentioned it only because some of us have been studying the relative timings of coding techniques, and this effect in AppleScript Editor, if not noticed and accounted for, could skew our results.
--Gil
Earlier messages:
On Sep 6, 2010, at 11:31 AM, Alex Zavatone wrote:
> Try clearing your variables in your init routines.
>
> If you do not have an init routine, where you initialize your variables, that is called from your run statement, you might want to think about adding one.
On Sep 6, 2010, at 7:44 AM, Nathan Greenstein wrote:
> Just out of curiosity, open Activity monitor and go to View-> Update Frequency-> Very Often. At the bottom, go to the System Memory tab. Set the Show menu in the top right to All Processes. Click the Real Memory column so that it has a downward-facing triangle to its right. Select the (Apple)Script Editor process.
> Then, to the beginning of your script, add a two second delay or so, and then a beep. Then start your script. And to the end, add another beep.
> delay 2
> beep
> ...
> beep
> Click Run in Script Editor, then go to Activity Monitor. Once it beeps, keep an eye on the memory graph at the bottom, and Script Editor's placement in the list. If the green Free portion of the graph decreases and/or Script Editor moves up in the list as you run the script, your script is using more and more memory as you go.
>
> If this is the case, we've found the what but not the why. I'm not sure how to get better performance out of AS Editor. One thing you could try is saving the script as its own app and trying then.
>
> HTH,
> --
> Nathan Greenstein
> email@hidden
On Sep 6, 2010, at 6:21 AM, KOENIG Yvan wrote:
> May you check if you are using some properties ?
>
> If you do, it would be useful to clear them when the script ends its task.
>
> Yvan KOENIG (VALLAURIS, France) lundi 6 septembre 2010 15:20:30
Le 6 sept. 2010 à 14:27, Gil Dawson a écrit :
> I do indeed use lots of recursion. I had thought that Script Editor would forget all about those recursive calls after the script exited, but I guess not.
>
> Here's a recent sequence: 35 ms, 60 ms, 88 ms, 138 ms, 160 ms, 180 ms.
>
> Oddly, Smile doesn't do this. It stays around 30 ms.
On Sep 5, 2010, at 10:42 PM, Ronald Hofmann wrote:
Well, this is hard to say without seeing the script.
But it sounds like you got some recursive calls of parts of the script which causes this behaviour.
Ronald
---
Am 06.09.2010 um 07:35 schrieb Gil Dawson:
> I have a rather long script which I run in Script Editor over and over several times. The central loop takes about 35ms the first time I run it, then 50ms the next time, then on and on... up to 400 ms after maybe a dozen runs, when I found out:
>
> Quitting and relaunching Script Editor resets the speed back to 35 ms.
>
> Does this seem odd?
>
> --Gil
_______________________________________________
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