factor/basis/tools/time/time.factor

25 lines
909 B
Factor
Raw Normal View History

! Copyright (C) 2003, 2010 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
USING: system kernel math namespaces io prettyprint tools.memory
2009-11-05 02:07:59 -05:00
tools.dispatch ;
2007-09-20 18:09:08 -04:00
IN: tools.time
: benchmark ( quot -- runtime )
nano-count [ call nano-count ] dip - ; inline
2008-05-07 18:42:41 -04:00
: time. ( time -- )
"Running time: " write 1000000000 /f pprint " seconds" print ;
2009-11-05 02:07:59 -05:00
: time-banner. ( -- )
"Additional information was collected." print
"dispatch-stats. - Print method dispatch statistics" print
"gc-events. - Print all garbage collection events" print
"gc-stats. - Print breakdown of different garbage collection events" print
"gc-summary. - Print aggregate garbage collection statistics" print flush ;
2007-09-20 18:09:08 -04:00
: time ( quot -- )
[
[ benchmark ] collect-dispatch-stats last-dispatch-stats set
] collect-gc-events gc-events set
2009-11-05 02:07:59 -05:00
time. nl time-banner. ; inline