]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/dispatch/dispatch.factor
Switch to https urls
[factor.git] / basis / tools / dispatch / dispatch.factor
1 ! Copyright (C) 2009, 2010 Slava Pestov.
2 ! See https://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 <PRIVATE
8 PRIMITIVE: dispatch-stats ( -- stats )
9 PRIMITIVE: reset-dispatch-stats ( -- )
10 PRIVATE>
11
12 SYMBOL: last-dispatch-stats
13
14 : dispatch-stats. ( -- )
15     last-dispatch-stats get {
16         { "Megamorphic hits" [ megamorphic-cache-hits>> ] }
17         { "Megamorphic misses" [ megamorphic-cache-misses>> ] }
18         { "Cold to monomorphic" [ cold-call-to-ic-transitions>> ] }
19         { "Mono to polymorphic" [ ic-to-pic-transitions>> ] }
20         { "Poly to megamorphic" [ pic-to-mega-transitions>> ] }
21         { "Tag check count" [ pic-tag-count>> ] }
22         { "Tuple check count" [ pic-tuple-count>> ] }
23     } object-table. ;
24
25 : collect-dispatch-stats ( quot -- dispatch-statistics )
26     reset-dispatch-stats
27     call
28     dispatch-stats dispatch-statistics memory>struct ; inline