std-timer-start, std-timer-stop


Synopsis

(std-timer-start) ; => timer, starts the stopclock

(std-timer-stop timer) ; elapses milliseconds

Description

They are used to compute the elapsed time in milliseconds.

Nested or incremental timer calls are supported by the timer argument to STD-TIMER-STOP. If the timer argument is nil the number of milliseconds since the last call to STD-TIMER-START is returned, otherwise the difference to the given timer argument.

Sideeffects

Both functions maybe used in a purely functional way, but you may also use both symbols for side-effects only. However, the interpretation of *STD:TIMER-START* is system dependent and not guaranteed to be exact milliseconds. It is normally only usable for numerical differences.

Example

(std-timer-start)
(std-sleep 0.5)
(std-princ (list "waited " (std-timer-stop nil) " ms"))

or:

(setq t1 (std-timer-start))
(repeat 5
  (std-timer-start)(std-sleep 0.1)
  (princ (std-timer-stop nil)))
(std-princ (list "\nsummary: " (std-timer-stop t1) " ms"))

Arguments

timer: Must be the return value from std-timer-start. This is usually a number (int or real).

Return Value

STD-TIMER-START returns a timer, usually a number (int or real) in milliseconds.

STD-TIMER-STOP returns a number (int or real) in milliseconds.

Side Effects

Sets and reads the global symbol *STD:TIMER-START*.

STD-TIMER-START stores a time number (units milliseconds) in a global symbol *STD:TIMER-START* to support the nil argument.

Module

(std-require 'STDTIME)

Defined in STDTIME