 : samples>time ( samples -- time )
     samples-per-second get-global / seconds ;
 
-: (total-time) ( samples -- n )
+: total-time* ( profile-data -- n )
     [ total-sample-count ] map-sum samples>time ;
 
-: (gc-time) ( samples -- n )
+: gc-time* ( profile-data -- n )
     [ gc-sample-count ] map-sum samples>time ;
 
-: (foreign-time) ( samples -- n )
+: foreign-time* ( profile-data -- n )
     [ foreign-sample-count ] map-sum samples>time ;
 
-: (foreign-thread-time) ( samples -- n )
+: foreign-thread-time* ( profile-data -- n )
     [ foreign-thread-sample-count ] map-sum samples>time ;
 
 : total-time ( -- n )
-    get-raw-profile-data (total-time) ;
+    most-recent-profile-data total-time* ;
 : gc-time ( -- n )
-    get-raw-profile-data (gc-time) ;
+    most-recent-profile-data gc-time* ;
 : foreign-time ( -- n )
-    get-raw-profile-data (foreign-time) ;
+    most-recent-profile-data foreign-time* ;
 : foreign-thread-time ( -- n )
-    get-raw-profile-data (foreign-thread-time) ;
+    most-recent-profile-data foreign-thread-time* ;
 
 : collect-threads ( samples -- by-thread )
     [ sample-thread ] collect-by ;
 
 : time-per-thread ( -- n )
-    get-raw-profile-data collect-threads [ (total-time) ] assoc-map ;
+    most-recent-profile-data collect-threads [ total-time* ] assoc-map ;
 
 : leaf-callstack? ( callstack -- ? )
     [ ignore-word? ] all? ;

    ] each
    per-word-samples [ f depth <profile-node> ] assoc-map ;

:: (cross-section) ( depth samples -- flat )
    samples collect-threads
    [ [ depth collect-cross-section ] <profile-root-node> ] assoc-map ;

: cross-section ( depth -- tree )
    get-raw-profile-data (cross-section) ;

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

: trim-root ( root -- root' )
    dup redundant-root-node? [ children>> values first trim-root ] when ;

:: (top-down) ( profile-data depth -- tree )
    profile-data collect-threads
    [ [ depth collect-tops ] <profile-root-node> trim-root ] assoc-map ;

: top-down* ( profile-data -- tree )
    0 (top-down) ;

: top-down ( -- tree )
    most-recent-profile-data top-down* ;

:: counts+at ( key assoc sample -- )
    key assoc [ zero-counts or sample sample-counts-slice v+ ] change-at ;
