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

Method mapSample

profile/merge.go:155–194  ·  view source on GitHub ↗
(src *Sample)

Source from the content-addressed store, hash-verified

153}
154
155func (pm *profileMerger) mapSample(src *Sample) *Sample {
156 // Check memoization table
157 k := pm.sampleKey(src)
158 if ss, ok := pm.samples[k]; ok {
159 for i, v := range src.Value {
160 ss.Value[i] += v
161 }
162 return ss
163 }
164
165 // Make new sample.
166 s := &Sample{
167 Location: make([]*Location, len(src.Location)),
168 Value: make([]int64, len(src.Value)),
169 Label: make(map[string][]string, len(src.Label)),
170 NumLabel: make(map[string][]int64, len(src.NumLabel)),
171 NumUnit: make(map[string][]string, len(src.NumLabel)),
172 }
173 for i, l := range src.Location {
174 s.Location[i] = pm.mapLocation(l)
175 }
176 for k, v := range src.Label {
177 vv := make([]string, len(v))
178 copy(vv, v)
179 s.Label[k] = vv
180 }
181 for k, v := range src.NumLabel {
182 u := src.NumUnit[k]
183 vv := make([]int64, len(v))
184 uu := make([]string, len(u))
185 copy(vv, v)
186 copy(uu, u)
187 s.NumLabel[k] = vv
188 s.NumUnit[k] = uu
189 }
190 copy(s.Value, src.Value)
191 pm.samples[k] = s
192 pm.p.Sample = append(pm.p.Sample, s)
193 return s
194}
195
196func (pm *profileMerger) sampleKey(sample *Sample) sampleKey {
197 // Accumulate contents into a string.

Callers 1

MergeFunction · 0.95

Calls 2

sampleKeyMethod · 0.95
mapLocationMethod · 0.95

Tested by

no test coverage detected