tools.memory, tools.dispatch: change collect-gc-events and collect-dispatch-stats combinators to output values instead of setting variables
parent
acb04ad3ed
commit
10836ce1bc
|
@ -1,4 +1,4 @@
|
||||||
! Copyright (C) 2009 Slava Pestov.
|
! Copyright (C) 2009, 2010 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors kernel namespaces prettyprint classes.struct
|
USING: accessors kernel namespaces prettyprint classes.struct
|
||||||
vm tools.dispatch.private ;
|
vm tools.dispatch.private ;
|
||||||
|
@ -17,8 +17,7 @@ SYMBOL: last-dispatch-stats
|
||||||
{ "Tuple check count" [ pic-tuple-count>> ] }
|
{ "Tuple check count" [ pic-tuple-count>> ] }
|
||||||
} object-table. ;
|
} object-table. ;
|
||||||
|
|
||||||
: collect-dispatch-stats ( quot -- )
|
: collect-dispatch-stats ( quot -- dispatch-stats )
|
||||||
reset-dispatch-stats
|
reset-dispatch-stats
|
||||||
call
|
call
|
||||||
dispatch-stats dispatch-statistics memory>struct
|
dispatch-stats dispatch-statistics memory>struct ; inline
|
||||||
last-dispatch-stats set ; inline
|
|
||||||
|
|
|
@ -90,12 +90,10 @@ PRIVATE>
|
||||||
] each 2drop
|
] each 2drop
|
||||||
] tabular-output nl ;
|
] tabular-output nl ;
|
||||||
|
|
||||||
SYMBOL: gc-events
|
: collect-gc-events ( quot -- gc-events )
|
||||||
|
|
||||||
: collect-gc-events ( quot -- )
|
|
||||||
enable-gc-events
|
enable-gc-events
|
||||||
[ ] [ disable-gc-events drop ] cleanup
|
[ ] [ 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
|
<PRIVATE
|
||||||
|
|
||||||
|
@ -164,6 +162,8 @@ TUPLE: gc-stats collections times ;
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
|
SYMBOL: gc-events
|
||||||
|
|
||||||
: gc-event. ( event -- )
|
: gc-event. ( event -- )
|
||||||
{
|
{
|
||||||
{ "Event type:" [ op>> gc-op-string ] }
|
{ "Event type:" [ op>> gc-op-string ] }
|
||||||
|
|
|
@ -27,11 +27,11 @@ HELP: time
|
||||||
{ benchmark system-micros time } related-words
|
{ benchmark system-micros time } related-words
|
||||||
|
|
||||||
HELP: collect-gc-events
|
HELP: collect-gc-events
|
||||||
{ $values { "quot" quotation } }
|
{ $values { "quot" quotation } { "gc-events" "a sequence of " { $link gc-event } " instances" } }
|
||||||
{ $description "Calls the quotation, storing an array of " { $link gc-event } " instances in the " { $link gc-events } " variable." }
|
{ $description "Calls the quotation and outputs a sequence of " { $link gc-event } " instances." }
|
||||||
{ $notes "The " { $link time } " combinator automatically calls this combinator." } ;
|
{ $notes "The " { $link time } " combinator automatically calls this combinator." } ;
|
||||||
|
|
||||||
HELP: collect-dispatch-stats
|
HELP: collect-dispatch-stats
|
||||||
{ $values { "quot" quotation } }
|
{ $values { "quot" quotation } { "dispatch-stats" dispatch-stats } }
|
||||||
{ $description "Calls the quotation, collecting method dispatch statistics and storing them in the " { $link last-dispatch-stats } " variable. " }
|
{ $description "Calls the quotation and outputs a " { $link dispatch-stats } " instance." }
|
||||||
{ $notes "The " { $link time } " combinator automatically calls this combinator." } ;
|
{ $notes "The " { $link time } " combinator automatically calls this combinator." } ;
|
||||||
|
|
|
@ -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.
|
! 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 ;
|
tools.dispatch ;
|
||||||
IN: tools.time
|
IN: tools.time
|
||||||
|
|
||||||
|
@ -18,5 +18,7 @@ IN: tools.time
|
||||||
"gc-summary. - Print aggregate garbage collection statistics" print ;
|
"gc-summary. - Print aggregate garbage collection statistics" print ;
|
||||||
|
|
||||||
: time ( quot -- )
|
: 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
|
time. nl time-banner. ; inline
|
||||||
|
|
Loading…
Reference in New Issue