LapTime
LapTime is an AppleScript library to measure execution time of AppleScript in accurary of a few milliseconds. It is useful to evaluate performance of a script and to tune up the script.
You can measure execution time by using current date command which is AppleScript's built-in command. But time resolution of AppleScript's date class is 1 sec, which is too rough for performance measurements. By using NSDate of Cocoa, the time resolution of LapTime is below a few msec.
The simple usage is using start_timer and duration methods. start_timer generate a new LapTime instance. duration method obtain elapsed time from call of start_timer.
To evaluate required times of parts of your script, use lap, lap_ and lap_times methods. lap and lap_ recorods the called time into the LapTime instance generaged by start_timer. lap_times method outputs elapsed times between each lap or lap_ methods and start_timer.
lap records only time. lap_ records time with a given label. The label apears in first column of log output of lap_times. The label will help to find the record in the log output.
For precise evaluations of required times of processings in your script, use lap and average. Reapeat execuion of your script many times with repeat statement ,and record each execution time with lap. average calculate an average of time diffrences between each lap and start_timer.
History
- 2.1.1 -- 2020-04-12
- Fixed : did not work in OS X 10.9
- 2.1 -- 2020-02-26
- Add "lap_" method.
- 2.0 -- 2020-02-12
- First release.
- Scripting additions don't work on macOS 10.14 or later. This libray is aimed to replace LapTime.oax.