sampleFormat returns a function to extract values out of a profile.Sample, and the type/units of those values.
(p *profile.Profile, sampleIndex string, mean bool)
| 366 | // sampleFormat returns a function to extract values out of a profile.Sample, |
| 367 | // and the type/units of those values. |
| 368 | func sampleFormat(p *profile.Profile, sampleIndex string, mean bool) (value, meanDiv sampleValueFunc, v *profile.ValueType, err error) { |
| 369 | if len(p.SampleType) == 0 { |
| 370 | return nil, nil, nil, fmt.Errorf("profile has no samples") |
| 371 | } |
| 372 | index, err := p.SampleIndexByName(sampleIndex) |
| 373 | if err != nil { |
| 374 | return nil, nil, nil, err |
| 375 | } |
| 376 | value = valueExtractor(index) |
| 377 | if mean { |
| 378 | meanDiv = valueExtractor(0) |
| 379 | } |
| 380 | v = p.SampleType[index] |
| 381 | return |
| 382 | } |
| 383 | |
| 384 | func valueExtractor(ix int) sampleValueFunc { |
| 385 | return func(v []int64) int64 { |
no test coverage detected
searching dependent graphs…