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

Function readProfile

internal/report/source_test.go:260–288  ·  view source on GitHub ↗
(fname string, t *testing.T)

Source from the content-addressed store, hash-verified

258}
259
260func readProfile(fname string, t *testing.T) *profile.Profile {
261 file, err := os.Open(fname)
262 if err != nil {
263 t.Fatalf("%s: could not open profile: %v", fname, err)
264 }
265 defer file.Close()
266 p, err := profile.Parse(file)
267 if err != nil {
268 t.Fatalf("%s: could not parse profile: %v", fname, err)
269 }
270
271 // Fix file names so they do not include absolute path names.
272 fix := func(s string) string {
273 const testdir = "/internal/report/"
274 pos := strings.Index(s, testdir)
275 if pos == -1 {
276 return s
277 }
278 return s[pos+len(testdir):]
279 }
280 for _, m := range p.Mapping {
281 m.File = fix(m.File)
282 }
283 for _, f := range p.Function {
284 f.Filename = fix(f.Filename)
285 }
286
287 return p
288}

Callers 2

TestWebListFunction · 0.85

Calls 3

ParseFunction · 0.92
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…