Render module graph.
This commit is contained in:
parent
693c88ff54
commit
a5f47f86e5
|
@ -3,7 +3,9 @@
|
||||||
(require racket/list unstable/list racket/match racket/set racket/format
|
(require racket/list unstable/list racket/match racket/set racket/format
|
||||||
racket/contract
|
racket/contract
|
||||||
(only-in racket/contract/private/guts contract-continuation-mark-key)
|
(only-in racket/contract/private/guts contract-continuation-mark-key)
|
||||||
"sampler.rkt" "utils.rkt")
|
"sampler.rkt" "utils.rkt"
|
||||||
|
;; for grphviz rendering
|
||||||
|
redex/private/dot racket/system)
|
||||||
|
|
||||||
(struct contract-profile
|
(struct contract-profile
|
||||||
(total-time n-samples n-contract-samples
|
(total-time n-samples n-contract-samples
|
||||||
|
@ -121,6 +123,9 @@
|
||||||
;; boundary.
|
;; boundary.
|
||||||
;; Typed modules are in green, untyped modules are in red.
|
;; Typed modules are in green, untyped modules are in red.
|
||||||
|
|
||||||
|
(define dot-exe (find-dot))
|
||||||
|
(define module-graph-dot-file "tmp-contract-profile-module-graph.dot")
|
||||||
|
|
||||||
(define (module-graph-view correlated)
|
(define (module-graph-view correlated)
|
||||||
(match-define (contract-profile total-time n-samples n-contract-samples
|
(match-define (contract-profile total-time n-samples n-contract-samples
|
||||||
live-contract-samples all-blames)
|
live-contract-samples all-blames)
|
||||||
|
@ -161,6 +166,9 @@
|
||||||
(values n typed?)))
|
(values n typed?)))
|
||||||
|
|
||||||
;; graphviz output
|
;; graphviz output
|
||||||
|
(with-output-to-file module-graph-dot-file
|
||||||
|
#:exists 'replace
|
||||||
|
(lambda ()
|
||||||
(printf "digraph {\n")
|
(printf "digraph {\n")
|
||||||
(define nodes->names (for/hash ([n nodes]) (values n (gensym))))
|
(define nodes->names (for/hash ([n nodes]) (values n (gensym))))
|
||||||
(for ([n nodes])
|
(for ([n nodes])
|
||||||
|
@ -174,7 +182,12 @@
|
||||||
(hash-ref nodes->names neg)
|
(hash-ref nodes->names neg)
|
||||||
(hash-ref nodes->names pos)
|
(hash-ref nodes->names pos)
|
||||||
(samples-time v)))
|
(samples-time v)))
|
||||||
(printf "}\n"))
|
(printf "}\n")))
|
||||||
|
;; render, if graphviz is installed
|
||||||
|
(when dot-exe
|
||||||
|
(system (format "~a -Tpdf -O ~a"
|
||||||
|
(path->string dot-exe)
|
||||||
|
module-graph-dot-file))))
|
||||||
|
|
||||||
|
|
||||||
;;---------------------------------------------------------------------------
|
;;---------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user