diff --git a/basis/tools/dispatch/dispatch.factor b/basis/tools/dispatch/dispatch.factor index 7d30dac36b..7ee89a50fb 100644 --- a/basis/tools/dispatch/dispatch.factor +++ b/basis/tools/dispatch/dispatch.factor @@ -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 diff --git a/basis/tools/memory/memory.factor b/basis/tools/memory/memory.factor index 0c55612466..1c999d979a 100644 --- a/basis/tools/memory/memory.factor +++ b/basis/tools/memory/memory.factor @@ -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 +SYMBOL: gc-events + : gc-event. ( event -- ) { { "Event type:" [ op>> gc-op-string ] } diff --git a/basis/tools/time/time-docs.factor b/basis/tools/time/time-docs.factor index d28202f844..ce9a621a2f 100644 --- a/basis/tools/time/time-docs.factor +++ b/basis/tools/time/time-docs.factor @@ -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." } ; diff --git a/basis/tools/time/time.factor b/basis/tools/time/time.factor index 0bd97f563d..8355f1f20c 100644 --- a/basis/tools/time/time.factor +++ b/basis/tools/time/time.factor @@ -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