]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/time/time.factor
Switch to https urls
[factor.git] / basis / tools / time / time.factor
1 ! Copyright (C) 2003, 2010 Slava Pestov.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: system kernel math namespaces io prettyprint tools.memory
4 tools.dispatch ;
5 IN: tools.time
6
7 : benchmark ( quot -- runtime )
8     nano-count [ call nano-count ] dip - ; inline
9
10 : time. ( time -- )
11     "Running time: " write 1000000000 /f pprint " seconds" print ;
12
13 : time-banner. ( -- )
14     "Additional information was collected." print
15     "dispatch-stats.  - Print method dispatch statistics" print
16     "gc-events.       - Print all garbage collection events" print
17     "gc-stats.        - Print breakdown of different garbage collection events" print
18     "gc-summary.      - Print aggregate garbage collection statistics" print flush ;
19
20 : time ( quot -- )
21     [
22         [ benchmark ] collect-dispatch-stats last-dispatch-stats set
23     ] collect-gc-events gc-events set
24     time. nl time-banner. ; inline