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

Function isPerfFile

internal/driver/fetch.go:554–569  ·  view source on GitHub ↗

isPerfFile checks if a file is in perf.data format. It also returns false if it encounters an error during the check.

(path string)

Source from the content-addressed store, hash-verified

552// isPerfFile checks if a file is in perf.data format. It also returns false
553// if it encounters an error during the check.
554func isPerfFile(path string) bool {
555 sourceFile, openErr := os.Open(path)
556 if openErr != nil {
557 return false
558 }
559 defer sourceFile.Close()
560
561 // If the file is the output of a perf record command, it should begin
562 // with the string PERFILE2.
563 perfHeader := []byte("PERFILE2")
564 actualHeader := make([]byte, len(perfHeader))
565 if _, readErr := sourceFile.Read(actualHeader); readErr != nil {
566 return false
567 }
568 return bytes.Equal(actualHeader, perfHeader)
569}
570
571// convertPerfData converts the file at path which should be in perf.data format
572// using the perf_to_profile tool and returns the file containing the

Callers 1

fetchFunction · 0.85

Calls 2

OpenMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…