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 )
2008-12-03 09:46:16 -05:00
micros [ call micros ] dip - ; inline
2008-05-07 18:42:41 -04:00
2008-05-08 00:09:18 -04:00
: time. ( data -- )
unclip
2008-11-23 04:10:32 -05:00
"==== RUNNING TIME" print nl 1000000 /f pprint " seconds" 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
{
2008-11-23 04:26:31 -05:00
"Total GC time (us):"
2008-05-08 00:09:18 -04:00
"Cards scanned:"
"Decks scanned:"
"Code heap literal scans:"
} swap zip simple-table.
] bi* ;
2007-09-20 18:09:08 -04:00
: time ( quot -- )
2008-12-03 09:46:16 -05:00
gc-reset micros [ call gc-stats micros ] dip - prefix time. ; inline