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

Function convertPerfData

internal/driver/fetch.go:574–590  ·  view source on GitHub ↗

convertPerfData converts the file at path which should be in perf.data format using the perf_to_profile tool and returns the file containing the profile.proto formatted data.

(perfPath string, ui plugin.UI)

Source from the content-addressed store, hash-verified

572// using the perf_to_profile tool and returns the file containing the
573// profile.proto formatted data.
574func convertPerfData(perfPath string, ui plugin.UI) (*os.File, error) {
575 ui.Print(fmt.Sprintf(
576 "Converting %s to a profile.proto... (May take a few minutes)",
577 perfPath))
578 profile, err := newTempFile(os.TempDir(), "pprof_", ".pb.gz")
579 if err != nil {
580 return nil, err
581 }
582 deferDeleteTempFile(profile.Name())
583 cmd := exec.Command("perf_to_profile", "-i", perfPath, "-o", profile.Name(), "-f")
584 cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
585 if err := cmd.Run(); err != nil {
586 profile.Close()
587 return nil, fmt.Errorf("failed to convert perf.data file. Try github.com/google/perf_data_converter: %v", err)
588 }
589 return profile, nil
590}
591
592// adjustURL validates if a profile source is a URL and returns an
593// cleaned up URL and the timeout to use for retrieval over HTTP.

Callers 1

fetchFunction · 0.85

Calls 5

newTempFileFunction · 0.85
deferDeleteTempFileFunction · 0.85
PrintMethod · 0.65
NameMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…