parseCPU parses a profilez legacy profile and returns a newly populated Profile. The general format for profilez samples is a sequence of words in binary format. The first words are a header with the following data: 1st word -- 0 2nd word -- 3 3rd word -- 0 if a c++ application, 1 if a java app
(b []byte)
| 302 | // 4th word -- Sampling period (in microseconds). |
| 303 | // 5th word -- Padding. |
| 304 | func parseCPU(b []byte) (*Profile, error) { |
| 305 | var parse func([]byte) (uint64, []byte) |
| 306 | var n1, n2, n3, n4, n5 uint64 |
| 307 | for _, parse = range cpuInts { |
| 308 | var tmp []byte |
| 309 | n1, tmp = parse(b) |
| 310 | n2, tmp = parse(tmp) |
| 311 | n3, tmp = parse(tmp) |
| 312 | n4, tmp = parse(tmp) |
| 313 | n5, tmp = parse(tmp) |
| 314 | |
| 315 | if tmp != nil && n1 == 0 && n2 == 3 && n3 == 0 && n4 > 0 && n5 == 0 { |
| 316 | b = tmp |
| 317 | return cpuProfile(b, int64(n4), parse) |
| 318 | } |
| 319 | if tmp != nil && n1 == 0 && n2 == 3 && n3 == 1 && n4 > 0 && n5 == 0 { |
| 320 | b = tmp |
| 321 | return javaCPUProfile(b, int64(n4), parse) |
| 322 | } |
| 323 | } |
| 324 | return nil, errUnrecognized |
| 325 | } |
| 326 | |
| 327 | // cpuProfile returns a new Profile from C++ profilez data. |
| 328 | // b is the profile bytes after the header, period is the profiling |
nothing calls this directly
no test coverage detected
searching dependent graphs…