factor/extra/tools/time/time.factor

37 lines
934 B
Factor
Raw Normal View History

2008-05-07 18:42:41 -04:00
! Copyright (C) 2003, 2008 Slava Pestov.
2007-09-20 18:09:08 -04:00
! See http://factorcode.org/license.txt for BSD license.
2008-05-07 18:42:41 -04:00
USING: kernel math math.vectors memory io io.styles prettyprint
namespaces system sequences assocs ;
2007-09-20 18:09:08 -04:00
IN: tools.time
: benchmark ( quot -- gctime runtime )
2008-05-07 18:42:41 -04:00
millis >r call millis r> - ; inline
: stats. ( data -- )
{
2008-05-07 22:54:41 -04:00
"Run time (ms):"
"Nursery GC time (ms):"
"Nursery GC #:"
"Aging GC time (ms):"
"Aging GC #:"
"Tenured GC time (ms):"
"Tenured GC #:"
"Cards scanned:"
"Decks scanned:"
"Code literal GC #:"
"Bytes copied:"
"Bytes collected:"
} swap zip
2008-05-07 18:42:41 -04:00
standard-table-style [
[
[
[ [ write ] with-cell ] [ pprint-cell ] bi*
] with-row
] assoc-each
] tabular-output ;
: stats gc-stats millis prefix ;
2007-09-20 18:09:08 -04:00
: time ( quot -- )
2008-05-07 18:42:41 -04:00
stats >r call stats r> v- stats. ; inline