Factor out dot rendering.
Can't use redex's version because it needs the GUI.
This commit is contained in:
parent
6bb906fb92
commit
fa63e0311f
|
@ -4,8 +4,7 @@
|
|||
racket/contract
|
||||
(only-in racket/contract/private/guts contract-continuation-mark-key)
|
||||
"sampler.rkt" "utils.rkt"
|
||||
;; for grphviz rendering
|
||||
redex/private/dot racket/system)
|
||||
"contract-profiler/dot.rkt")
|
||||
|
||||
(struct contract-profile
|
||||
(total-time n-samples n-contract-samples
|
||||
|
@ -130,7 +129,6 @@
|
|||
;; boundary.
|
||||
;; 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)
|
||||
|
@ -195,10 +193,7 @@
|
|||
(samples-time v)))
|
||||
(printf "}\n")))
|
||||
;; render, if graphviz is installed
|
||||
(when dot-exe
|
||||
(system (format "~a -Tpdf -O ~a"
|
||||
(path->string dot-exe)
|
||||
module-graph-dot-file))))
|
||||
(render-dot module-graph-dot-file))
|
||||
|
||||
|
||||
;;---------------------------------------------------------------------------
|
||||
|
|
29
collects/profile/contract-profiler/dot.rkt
Normal file
29
collects/profile/contract-profiler/dot.rkt
Normal file
|
@ -0,0 +1,29 @@
|
|||
#lang racket/base
|
||||
|
||||
;; Graphviz support
|
||||
;; inspired by redex/private/dot.rkt (can't use directly because it uses GUI)
|
||||
|
||||
(require racket/system)
|
||||
|
||||
(provide render-dot)
|
||||
|
||||
;; these paths are explicitly checked (when find-executable-path
|
||||
;; fails) because starting drracket from the finder (or the dock)
|
||||
;; under mac os x generally does not get the path right.
|
||||
(define dot-paths
|
||||
'("/usr/bin"
|
||||
"/bin"
|
||||
"/usr/local/bin"
|
||||
"/opt/local/bin/"))
|
||||
|
||||
(define dot.exe (if (eq? (system-type) 'windows) "dot.exe" "dot"))
|
||||
(define dot
|
||||
(or (find-executable-path dot.exe)
|
||||
(ormap (λ (x)
|
||||
(define candidate (build-path x dot.exe))
|
||||
(and (file-exists? candidate) candidate))
|
||||
dot-paths)))
|
||||
|
||||
(define (render-dot input-file)
|
||||
(when dot
|
||||
(system (format "~a -Tpdf -O ~a" (path->string dot) input-file))))
|
Loading…
Reference in New Issue
Block a user