Timing code and collecting statistics (original) (raw)

You can time the execution of a quotation in the listener:
time ( quot -- )

This word also collects statistics about method dispatch and garbage collection:

dispatch-stats. ( -- )

gc-events. ( -- )
gc-stats. ( -- )
gc-summary. ( -- )

A lower-level word puts timings on the stack, instead of printing:

benchmark ( quot -- runtime )

You can also read the system clock directly; see System interface.

See also
Sampling profiler, Word annotations, Calendar