code: func cpuProfile(b []byte, period int64, parse func(b []byte) (uint64, []byte)) (*Profile, error) {
  	p := &Profile{
  		Period:     period * 1000,
  		PeriodType: &ValueType{Type: "cpu", Unit: "nanoseconds"},
  		SampleType: []*ValueType{
  			{Type: "samples", Unit: "count"},
  			{Type: "cpu", Unit: "nanoseconds"},
  		},
  	}
  	var err error
  	if b, _, err = parseCPUSamples(b, parse, true, p); err != nil {
  		return nil, err
  	}
  
  	// If all samples have the same second-to-the-bottom frame, it
  	// strongly suggests that it is an uninteresting artifact of
  	// measurement -- a stack frame pushed by the signal handler. The
  	// bottom frame is always correct as it is picked up from the signal
  	// structure, not the stack. Check if this is the case and if so,
  	// remove.
  	if len(p.Sample) > 1 && len(p.Sample[0].Location) > 1 {
  		allSame := true
  		id1 := p.Sample[0].Location[1].Address
  		for _, s := range p.Sample {
  			if len(s.Location) < 2 || id1 != s.Location[1].Address {
  				allSame = false
  				break
  			}
  		}
  		if allSame {
  			for _, s := range p.Sample {
  				s.Location = append(s.Location[:1], s.Location[2:]...)
  			}
  		}
  	}
  
  	if err := p.ParseMemoryMap(bytes.NewBuffer(b)); err != nil {
  		return nil, err
  	}
  	return p, nil
  }
docs: // cpuProfile returns a new Profile from C++ profilez data.
  // b is the profile bytes after the header, period is the profiling
  // period, and parse is a function to parse 8-byte chunks from the
  // profile in its native endianness.