// Merge merges all the profiles in profs into a single Profile. // Returns a new profile independent of the input profiles. The merged // profile is compacted to eliminate unused samples, locations, // functions and mappings. Profiles must have identical profile sample // and period types or the merge will fail. profile.Period of the // resulting profile will be the maximum of all profiles, and // profile.TimeNanos will be the earliest nonzero one. func Merge(srcs []*Profile) (*Profile, error) { … } // Normalize normalizes the source profile by multiplying each value in profile by the // ratio of the sum of the base profile's values of that sample type to the sum of the // source profile's value of that sample type. func (p *Profile) Normalize(pb *Profile) error { … } func isZeroSample(s *Sample) bool { … } type profileMerger … type mapInfo … func (pm *profileMerger) mapSample(src *Sample) *Sample { … } // key generates sampleKey to be used as a key for maps. func (sample *Sample) key() sampleKey { … } type sampleKey … func (pm *profileMerger) mapLocation(src *Location) *Location { … } // key generates locationKey to be used as a key for maps. func (l *Location) key() locationKey { … } type locationKey … func (pm *profileMerger) mapMapping(src *Mapping) mapInfo { … } // key generates encoded strings of Mapping to be used as a key for // maps. func (m *Mapping) key() mappingKey { … } type mappingKey … func (pm *profileMerger) mapLine(src Line) Line { … } func (pm *profileMerger) mapFunction(src *Function) *Function { … } // key generates a struct to be used as a key for maps. func (f *Function) key() functionKey { … } type functionKey … // combineHeaders checks that all profiles can be merged and returns // their combined profile. func combineHeaders(srcs []*Profile) (*Profile, error) { … } // compatible determines if two profiles can be compared/merged. // returns nil if the profiles are compatible; otherwise an error with // details on the incompatibility. func (p *Profile) compatible(pb *Profile) error { … } // equalValueType returns true if the two value types are semantically // equal. It ignores the internal fields used during encode/decode. func equalValueType(st1, st2 *ValueType) bool { … }