]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/dispatch/dispatch.factor
72830b29b44a28d7f724021f6116864989582d55
[factor.git] / basis / tools / dispatch / dispatch.factor
1 ! Copyright (C) 2009, 2010 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel namespaces prettyprint classes.struct
4 vm tools.dispatch.private ;
5 IN: tools.dispatch
6
7 SYMBOL: last-dispatch-stats
8
9 : dispatch-stats. ( -- )
10     last-dispatch-stats get {
11         { "Megamorphic hits" [ megamorphic-cache-hits>> ] }
12         { "Megamorphic misses" [ megamorphic-cache-misses>> ] }
13         { "Cold to monomorphic" [ cold-call-to-ic-transitions>> ] }
14         { "Mono to polymorphic" [ ic-to-pic-transitions>> ] }
15         { "Poly to megamorphic" [ pic-to-mega-transitions>> ] }
16         { "Tag check count" [ pic-tag-count>> ] }
17         { "Tuple check count" [ pic-tuple-count>> ] }
18     } object-table. ;
19
20 : collect-dispatch-stats ( quot -- dispatch-statistics )
21     reset-dispatch-stats
22     call
23     dispatch-stats dispatch-statistics memory>struct ; inline