tools.profiler.sampling: twiddle output format

db4
Joe Groff 2011-11-02 21:40:31 -07:00
parent 2d87b68a56
commit f71187c775
1 changed files with 10 additions and 11 deletions

View File

@ -4,7 +4,7 @@ combinators.short-circuit continuations fry generalizations
hashtables.identity io kernel kernel.private locals math hashtables.identity io kernel kernel.private locals math
math.statistics math.vectors memory namespaces prettyprint math.statistics math.vectors memory namespaces prettyprint
sequences sequences.generalizations sets sorting sequences sequences.generalizations sets sorting
tools.profiler.sampling.private ; tools.profiler.sampling.private math.parser.private ;
FROM: sequences => change-nth ; FROM: sequences => change-nth ;
FROM: assocs => change-at ; FROM: assocs => change-at ;
IN: tools.profiler.sampling IN: tools.profiler.sampling
@ -136,27 +136,26 @@ TUPLE: profile-node
get-raw-profile-data (flat) ; get-raw-profile-data (flat) ;
: depth. ( depth -- ) : depth. ( depth -- )
[ " " write ] times ; [ "| " write ] times ;
: by-total-time ( nodes -- nodes' ) : by-total-time ( nodes -- nodes' )
>alist [ second total-time>> ] inv-sort-with ; >alist [ second total-time>> ] inv-sort-with ;
: duration. ( duration -- ) : duration. ( duration -- )
samples-per-second get-global { duration>milliseconds >float "%9.1fms" format-float write ;
{ [ dup 1000 <= ] [ drop duration>milliseconds >integer pprint "ms" write ] }
{ [ dup 1,000,000 <= ] [ drop duration>microseconds >integer pprint "µs" write ] } : percentage. ( num denom -- )
[ drop duration>nanoseconds >integer pprint "ns" write ] [ duration>seconds ] bi@ [ 100 * ] dip /f "%6.2f%%" format-float write ;
} cond ;
DEFER: (profile.) DEFER: (profile.)
: times. ( node -- ) : times. ( node -- )
{ {
[ total-time>> duration. ] [ total-time>> duration. ]
[ " (GC:" write gc-time>> duration. ] [ " (GC:" write [ gc-time>> ] [ total-time>> ] bi percentage. ]
[ ", JIT:" write jit-time>> duration. ] [ ", JIT:" write [ jit-time>> ] [ total-time>> ] bi percentage. ]
[ ", FFI:" write foreign-time>> duration. ] [ ", FFI:" write [ foreign-time>> ] [ total-time>> ] bi percentage. ]
[ ", FT:" write foreign-thread-time>> duration. ")" write ] [ ", FT:" write [ foreign-thread-time>> ] [ total-time>> ] bi percentage. ")" write ]
} cleave ; } cleave ;
:: (profile-node.) ( word node depth -- ) :: (profile-node.) ( word node depth -- )