Re: Optimize your script with Shark
Re: Optimize your script with Shark
- Subject: Re: Optimize your script with Shark
- From: Daniel Jalkut <email@hidden>
- Date: Mon, 17 Oct 2005 21:19:05 -0400
On Oct 17, 2005, at 8:24 PM, has wrote: That's not really what profilers are about. For comparing individual algorithms as your example does, it's a lot simpler to use a timing osax like GetMilliSec and wrap the code to test in something like the following:
[EXAMPLE SNIPPED]
I'm not sure why I'd want to use a 3rd party osax to get millisecond timings when I get that and a whole lot more by tapping into the Apple standard performance tools. The examples in my write-up are trivial but even as-is they make it exceedingly easy to tell how much of the time is spent in for instance the shell tool, Script Editor itself, or inside OSA.
Where profilers are useful is in running whole-program analyses to see which *subroutines* your program spends the most of its time in. The idea is you use the profiler to quickly and easily identify the three or four routines where the program spends the majority of its time, so that you know which parts of your program to selectively optimise in order to get the biggest performance improvement for the minimum amount of work. For AppleScripters, that means measuring the time spent in each AS handler - you don't need or want to see the details of anything else (i.e. machine-level calls occurring within the AS interpreter, the host app or any remote apps called from the script). I've not used Shark myself, but would be a little surprised if it could provide that sort of information since interpreter-level calls operate on a different level to machine-level calls. (Though if you can find a way to do it, do tell...)
You're right that Shark doesn't provide this level of information, but that doesn't make the information it does provide useless. If I profile my script and it shows that 70% of my time is spent in a particular system API, then you can bet I'll be looking into what part of my script is indirectly leading to that system call. Yes, it's pretty useless for completely self-contained scripts whose functionality never reaches a system API or another process. I do agree that a profiler for AS would be a nice thing to have (assuming the user has the programming skills to use it productively), but it's really something that needs to hook directly into the AS interpreter itself, which means Apple would have to provide it. (i.e. Don't hold your breath.) Of course, you can profile AS code with nothing but a timing osax and a bit of manual work if/when you really have to; it's just more convenient with an automated tool if you have one. I'm sorry you don't see the value of triggering Shark from an AppleScript. I think it's a heck of a lot closer to what you're wishing for than anything else we have access to at the moment, and Shark only continues to improve over time.
Daniel
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden