 combinators.short-circuit continuations fry io kernel
 kernel.private locals math math.statistics math.vectors memory
 namespaces prettyprint sequences sorting
-tools.profiler.sampling.private ;
+tools.profiler.sampling.private hashtables.identity generalizations ;
 FROM: sequences => change-nth ;
+FROM: assocs => change-at ;
 IN: tools.profiler.sampling
 
 SYMBOL: raw-profile-data

    dup redundant-root-node? [ children>> values first trim-root ] when ;

: (top-down) ( samples -- tree )
    collect-contexts [
        [ sum-times ] [ collect-tops ] bi <profile-node> trim-root
    ] assoc-map ;

: top-down ( -- tree )
    get-raw-profile-data (top-down) ;

: depth. ( depth -- )
    [ "  " write ] times ;

: gc-sample-count ( sample -- count ) second ;
: foreign-sample-count ( sample -- count ) third ;
: foreign-thread-sample-count ( sample -- count ) fourth ;
: sample-thread ( sample -- alien ) 4 swap nth ;
: sample-callstack ( sample -- array ) 5 swap nth ;

: samples>time ( samples -- time )
