 ! (c)2011 Joe Groff bsd license
-USING: accessors assocs calendar combinators
+USING: accessors assocs combinators
 combinators.short-circuit continuations fry generalizations
 hashtables.identity io kernel kernel.private layouts locals
 math math.parser math.parser.private math.statistics

: unclip-callstack ( sample -- sample' callstack-top )
    clone 6 over [ unclip swap ] change-nth ;

: samples>time ( samples -- time )
    samples-per-second get-global / seconds ;

: total-time* ( profile-data -- n )
    [ total-sample-count ] map-sum samples>time ;

    >alist [ second total-time>> ] inv-sort-with ;

: duration. ( duration -- )
    1000 * >float "%9.1f" format-float write ;

: percentage. ( num denom -- )
    [ 100 * ] dip /f "%6.2f" format-float write ;

DEFER: (profile.)

