factor/basis/tools/time/time.factor

41 lines
1.1 KiB
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
2008-06-09 06:22:21 -04:00
namespaces system sequences splitting grouping assocs strings ;
2007-09-20 18:09:08 -04:00
IN: tools.time
: benchmark ( quot -- runtime )
micros >r call micros r> - ; inline
2008-05-07 18:42:41 -04:00
2008-05-08 00:09:18 -04:00
: time. ( data -- )
unclip
"==== RUNNING TIME" print nl pprint " us" print nl
2008-05-08 00:09:18 -04:00
4 cut*
"==== GARBAGE COLLECTION" print nl
[
6 group
{
"GC count:"
"Cumulative GC time (us):"
"Longest GC pause (us):"
"Average GC pause (us):"
2008-05-08 00:09:18 -04:00
"Objects copied:"
"Bytes copied:"
} prefix
flip
{ "" "Nursery" "Aging" "Tenured" } prefix
simple-table.
]
[
nl
{
"Total GC time (ms):"
"Cards scanned:"
"Decks scanned:"
"Code heap literal scans:"
} swap zip simple-table.
] bi* ;
2007-09-20 18:09:08 -04:00
: time ( quot -- )
gc-reset micros >r call gc-stats micros r> - prefix time. ; inline