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-05-08 00:09:18 -04:00
|
|
|
namespaces system sequences splitting assocs strings ;
|
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
|
|
|
|
|
2008-05-08 00:09:18 -04:00
|
|
|
: simple-table. ( values -- )
|
2008-05-07 18:42:41 -04:00
|
|
|
standard-table-style [
|
|
|
|
[
|
|
|
|
[
|
2008-05-08 00:09:18 -04:00
|
|
|
[
|
|
|
|
dup string?
|
|
|
|
[ [ write ] with-cell ]
|
|
|
|
[ pprint-cell ]
|
|
|
|
if
|
|
|
|
] each
|
2008-05-07 18:42:41 -04:00
|
|
|
] with-row
|
2008-05-08 00:09:18 -04:00
|
|
|
] each
|
2008-05-07 18:42:41 -04:00
|
|
|
] tabular-output ;
|
|
|
|
|
2008-05-08 00:09:18 -04:00
|
|
|
: time. ( data -- )
|
|
|
|
unclip
|
|
|
|
"==== RUNNING TIME" print nl pprint " ms" print nl
|
|
|
|
4 cut*
|
|
|
|
"==== GARBAGE COLLECTION" print nl
|
|
|
|
[
|
|
|
|
6 group
|
|
|
|
{
|
|
|
|
"GC count:"
|
|
|
|
"Cumulative GC time (ms):"
|
|
|
|
"Longest GC pause (ms):"
|
|
|
|
"Average GC pause (ms):"
|
|
|
|
"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 -- )
|
2008-05-08 00:09:18 -04:00
|
|
|
gc-reset millis >r call gc-stats millis r> - prefix time. ; inline
|