MCPcopy Create free account
hub / github.com/google/pprof / dotToSvg

Function dotToSvg

internal/driver/webui.go:347–363  ·  view source on GitHub ↗
(dot []byte)

Source from the content-addressed store, hash-verified

345}
346
347func dotToSvg(dot []byte) ([]byte, error) {
348 cmd := exec.Command("dot", "-Tsvg")
349 out := &bytes.Buffer{}
350 cmd.Stdin, cmd.Stdout, cmd.Stderr = bytes.NewBuffer(dot), out, os.Stderr
351 if err := cmd.Run(); err != nil {
352 return nil, err
353 }
354
355 // Fix dot bug related to unquoted ampersands.
356 svg := bytes.ReplaceAll(out.Bytes(), []byte("&;"), []byte("&;"))
357
358 // Cleanup for embedding by dropping stuff before the <svg> start.
359 if pos := bytes.Index(svg, []byte("<svg")); pos >= 0 {
360 svg = svg[pos:]
361 }
362 return svg, nil
363}
364
365func (ui *webInterface) top(w http.ResponseWriter, req *http.Request) {
366 rpt, errList := ui.makeReport(w, req, []string{"top"}, func(cfg *config) {

Callers 1

dotMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…