Home > Software >

Requirements

  • Mac OS X 10.4 or later
    • Developed and tested on Mac OS X 10.5.8, 10.8.5

Download

Version 1.0.3 -- 2016-02-17

LapTime

LapTime.osax is a scripting addition to measure execution time of a script of AppleScript. It is useful to evaluate performance of the 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. The time resolution of LapTime.osax is under a few msec.

You can obtain time differences bettween commands of LapTime.osax as follows. The simple usage is using "start timer" and "stop timer". "start timer" generate a new timer object. "stop timer" command obtain elapsed time from "start timer" command.

set tm to start timer
(* beginning of tasks *)
beep
delay 0.5
(* end of tasks*)
stop timer tm
-- result : 814.49609375 [msec]

To obtain a time at a certain point in the script, you can use "lap time" command. The "lap time" commands record elapsed time since "start timer" command or previous "lap time" command. These time records are obtained by "time records of" command.

set tm to start timer
(* beginning of tasks *)
beep
lap time tm
delay 0.5
lap time tm
delay 0.01
(* end of tasks*)
time records of tm
(* result :
lap times:
{3.222900390625, 501.865966796875, 10.423095703125},
total times:515.511962890625
*)

When you evaluate performance of a script using LapTime.osax on Script Editor or AppleScript Editor, log of AppleScript should be tuned off. Becase logging AppleScript execution will affect the performance and times recorded by LapTime.osax.

History

  • 1.0.3 -- 2016-02-17
    • Compiled with garbage collection support.
  • 1.0.2 -- 2010-12-17
    • Fixed an error when a process quit on Mac OS X 10.4.
  • 1.0.1 -- 2010-12-12
    • Supported Mac OS X 10.4.
  • 1.0 -- 2010-10-19
    • First release.