code: func (p *Profile) Merge(pb *Profile, r float64) error {
  	if err := p.Compatible(pb); err != nil {
  		return err
  	}
  
  	pb = pb.Copy()
  
  	// Keep the largest of the two periods.
  	if pb.Period > p.Period {
  		p.Period = pb.Period
  	}
  
  	p.DurationNanos += pb.DurationNanos
  
  	p.Mapping = append(p.Mapping, pb.Mapping...)
  	for i, m := range p.Mapping {
  		m.ID = uint64(i + 1)
  	}
  	p.Location = append(p.Location, pb.Location...)
  	for i, l := range p.Location {
  		l.ID = uint64(i + 1)
  	}
  	p.Function = append(p.Function, pb.Function...)
  	for i, f := range p.Function {
  		f.ID = uint64(i + 1)
  	}
  
  	if r != 1.0 {
  		for _, s := range pb.Sample {
  			for i, v := range s.Value {
  				s.Value[i] = int64((float64(v) * r))
  			}
  		}
  	}
  	p.Sample = append(p.Sample, pb.Sample...)
  	return p.CheckValid()
  }
docs: // Merge adds profile p adjusted by ratio r into profile p. Profiles
  // must be compatible (same Type and SampleType).
  // TODO(rsilvera): consider normalizing the profiles based on the
  // total samples collected.