Beispiel #1
0
Datei: gom.go Projekt: lewgun/gom
// Filter filters the report with a focus regex. If no focus is provided,
// it reports back with the entire set of calls.
// Focus regex works on the package, type and function names. Filtered
// results will include parent samples from the call graph.
func (r *Report) Filter(w io.Writer, cum bool, focus *regexp.Regexp) {
	// TODO(jbd): Support ignore and hide regex parameters.
	if r.p == nil {
		return
	}
	c := r.p.Copy()
	c.FilterSamplesByName(focus, nil, nil)
	rpt := report.NewDefault(c, report.Options{
		OutputFormat:   report.JSON,
		CumSort:        cum,
		PrintAddresses: true,
	})
	report.Generate(w, rpt, nil)
}
Beispiel #2
0
Datei: gom.go Projekt: lewgun/gom
func (r *Report) Draw(w io.Writer, cum bool, focus *regexp.Regexp) error {
	// TODO(jbd): Support ignore and hide regex parameters.
	if r.p == nil {
		return errors.New("no such profile")
	}
	c := r.p.Copy()
	c.FilterSamplesByName(focus, nil, nil)
	rpt := report.NewDefault(c, report.Options{
		OutputFormat: report.Dot,
		CumSort:      cum,
	})
	data := bytes.NewBuffer(nil)
	report.Generate(data, rpt, nil)
	cmd := exec.Command("dot", "-Tsvg")
	in, _ := cmd.StdinPipe()
	_, err := io.Copy(in, data)
	if err != nil {
		return err
	}
	in.Close()
	out, err := cmd.Output()
	_, err = w.Write(out)
	return err
}