tools.memory, tools.dispatch: change collect-gc-events and collect-dispatch-stats combinators to output values instead of setting variables

db4
Slava Pestov 2010-03-16 14:00:15 +13:00
parent acb04ad3ed
commit 10836ce1bc
4 changed files with 16 additions and 15 deletions

View File

@ -1,4 +1,4 @@
! Copyright (C) 2009 Slava Pestov.
! Copyright (C) 2009, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors kernel namespaces prettyprint classes.struct
vm tools.dispatch.private ;
@ -17,8 +17,7 @@ SYMBOL: last-dispatch-stats
{ "Tuple check count" [ pic-tuple-count>> ] }
} object-table. ;
: collect-dispatch-stats ( quot -- )
: collect-dispatch-stats ( quot -- dispatch-stats )
reset-dispatch-stats
call
dispatch-stats dispatch-statistics memory>struct
last-dispatch-stats set ; inline
dispatch-stats dispatch-statistics memory>struct ; inline

View File

@ -90,12 +90,10 @@ PRIVATE>
] each 2drop
] tabular-output nl ;
SYMBOL: gc-events
: collect-gc-events ( quot -- )
: collect-gc-events ( quot -- gc-events )
enable-gc-events
[ ] [ disable-gc-events drop ] cleanup
disable-gc-events [ gc-event memory>struct ] map gc-events set ; inline
disable-gc-events [ gc-event memory>struct ] map ; inline
<PRIVATE
@ -164,6 +162,8 @@ TUPLE: gc-stats collections times ;
PRIVATE>
SYMBOL: gc-events
: gc-event. ( event -- )
{
{ "Event type:" [ op>> gc-op-string ] }

View File

@ -27,11 +27,11 @@ HELP: time
{ benchmark system-micros time } related-words
HELP: collect-gc-events
{ $values { "quot" quotation } }
{ $description "Calls the quotation, storing an array of " { $link gc-event } " instances in the " { $link gc-events } " variable." }
{ $values { "quot" quotation } { "gc-events" "a sequence of " { $link gc-event } " instances" } }
{ $description "Calls the quotation and outputs a sequence of " { $link gc-event } " instances." }
{ $notes "The " { $link time } " combinator automatically calls this combinator." } ;
HELP: collect-dispatch-stats
{ $values { "quot" quotation } }
{ $description "Calls the quotation, collecting method dispatch statistics and storing them in the " { $link last-dispatch-stats } " variable. " }
{ $values { "quot" quotation } { "dispatch-stats" dispatch-stats } }
{ $description "Calls the quotation and outputs a " { $link dispatch-stats } " instance." }
{ $notes "The " { $link time } " combinator automatically calls this combinator." } ;

View File

@ -1,6 +1,6 @@
! Copyright (C) 2003, 2009 Slava Pestov.
! Copyright (C) 2003, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: system kernel math io prettyprint tools.memory
USING: system kernel math namespaces io prettyprint tools.memory
tools.dispatch ;
IN: tools.time
@ -18,5 +18,7 @@ IN: tools.time
"gc-summary. - Print aggregate garbage collection statistics" print ;
: time ( quot -- )
[ [ benchmark ] collect-dispatch-stats ] collect-gc-events
[
[ benchmark ] collect-dispatch-stats last-dispatch-stats set
] collect-gc-events gc-events set
time. nl time-banner. ; inline