// ProfileGet gets the relevant read function for the profile or nil if it doesn't exist.
432210
func ProfileGet(name string) func(context.Context) ([]byte, time.Time, error) {
	p := pprof.Lookup(name)
	if p == nil {
		return nil
	}

	// See https://golang.org/pkg/runtime/pprof/#Profile.WriteTo
	// for the meaning of debug.
	debug := 1
	if name == "goroutine" {
		debug = 2
	}
	return profileRead(p, debug)
}
707321
func Get() (la LoadAvg, err error) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std, err = NewProfiler()
		if err != nil {
			return la, err
		}
	}
	return std.Get()
}
1166712
func httpGetAppProfile(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
	log.Debugf("Received httpGetAppProfile: %+v", vars)

	key := vars["key"]

	collections.appProfileMutex.Lock()
	defer collections.appProfileMutex.Unlock()
	obj := collections.appProfiles[key]
	if obj == nil {
		log.Infof("appProfile %s not found", key)
		return nil, errors.New("appProfile not found")
	}

	// Return the obj
	return obj, nil
}
366735
func (provider *GoogleProvider) GetUser(creds *common.Credentials) (common.User, error) {

	profileData, err := provider.Get(creds, googleEndpointProfile)

	if err != nil {
		return nil, err
	}

	// build user
	user := NewUser(profileData, creds, provider)

	return user, nil
}
156228
func GetProfile(scheme, emailHash string) (g GravatarProfile, err error) {
	url := &url.URL{
		Scheme: scheme,
		Host:   gravatarHost,
		Path:   "/" + emailHash + ".json",
	}

	err = run(url, unmarshal_json(&g))
	return
}
50131
func loadProfile(filename, profile string) (*ini.Section, error) {
	config, err := ini.Load(filename)
	if err != nil {
		return nil, err
	}
	iniProfile, err := config.GetSection(profile)
	if err != nil {
		return nil, err
	}
	return iniProfile, nil
}
4783
func (prof *Profiler) Get() (inf *Info, err error) {
	var (
		i, pos, nameLen int
		v               byte
		n               uint64
	)
	err = prof.Reset()
	if err != nil {
		return nil, err
	}
	inf = &Info{}
	inf.Timestamp = time.Now().UTC().UnixNano()
	for {
		prof.Val = prof.Val[:0]
		prof.Line, err = prof.ReadSlice('\n')
		if err != nil {
			if err == io.EOF {
				break
			}
			return inf, &joe.ReadError{Err: err}
		}
		// first grab the key name (everything up to the ':')
		for i, v = range prof.Line {
			if v == ':' {
				pos = i + 1
				break
			}
			prof.Val = append(prof.Val, v)
		}
		nameLen = len(prof.Val)

		// skip all spaces
		for i, v = range prof.Line[pos:] {
			if v != ' ' {
				pos += i
				break
			}
		}

		// grab the numbers
		for _, v = range prof.Line[pos:] {
			if v == ' ' || v == '\n' {
				break
			}
			prof.Val = append(prof.Val, v)
		}
		// any conversion error results in 0
		n, err = helpers.ParseUint(prof.Val[nameLen:])
		if err != nil {
			return inf, &joe.ParseError{Info: string(prof.Val[:nameLen]), Err: err}
		}

		v = prof.Val[0]
		// evaluate the key
		if v == 'A' {
			if prof.Val[5] == 'e' && nameLen == 6 {
				inf.Active = n
			}
			continue
		}
		if v == 'I' {
			if nameLen == 8 {
				inf.Inactive = n
			}
			continue
		}
		if v == 'M' {
			v = prof.Val[3]
			if nameLen < 8 {
				if v == 'p' {
					inf.Mapped = n
					continue
				}
				if v == 'F' {
					inf.MemFree = n
				}
				continue
			}
			if v == 'A' {
				inf.MemAvailable = n
				continue
			}
			inf.MemTotal = n
			continue
		}
		if v == 'S' {
			v = prof.Val[1]
			if v == 'w' {
				if prof.Val[4] == 'C' {
					inf.SwapCached = n
					continue
				}
				if prof.Val[4] == 'F' {
					inf.SwapFree = n
					continue
				}
				inf.SwapTotal = n
				continue
			}
		}
	}
	return inf, nil
}
1061754
func (u *User) Profile() (interface{}, error) {
	urlStr := GetApiBaseURL() + "/user/"
	return u.c.execute("GET", urlStr, "")
}
300328
func ProfileHandler() echo.HandlerFunc {
	return func(ctx echo.Context) error {
		Profile(ctx)
		return nil
	}
}
562844
func (adm *AdminClient) DownloadProfilingData() (io.ReadCloser, error) {
	path := fmt.Sprintf("/v1/profiling/download")
	resp, err := adm.executeMethod("GET", requestData{
		relPath: path,
	})

	if err != nil {
		closeResponse(resp)
		return nil, err
	}

	if resp.StatusCode != http.StatusOK {
		return nil, httpRespToErrorResponse(resp)
	}

	if resp.Body == nil {
		return nil, errors.New("body is nil")
	}

	return resp.Body, nil
}
1295381
func (a *Client) GetProfilesLibraryIdentifier(params *GetProfilesLibraryIdentifierParams, authInfo runtime.ClientAuthInfoWriter) (*GetProfilesLibraryIdentifierOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetProfilesLibraryIdentifierParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "GetProfilesLibraryIdentifier",
		Method:             "GET",
		PathPattern:        "/profiles/library/{identifier}",
		ProducesMediaTypes: []string{"application/json", "application/x-gzip"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &GetProfilesLibraryIdentifierReader{formats: a.formats},
		AuthInfo:           authInfo,
	})
	if err != nil {
		return nil, err
	}
	return result.(*GetProfilesLibraryIdentifierOK), nil
}
1024592
func (prof *Profiler) Get() (la LoadAvg, err error) {
	err = prof.Reset()
	if err != nil {
		return la, err
	}
	var (
		i, priorPos, pos, line, fieldNum int
		n                                uint64
		f                                float64
		v                                byte
	)
	la.Timestamp = time.Now().UTC().UnixNano()
	for {
		prof.Line, err = prof.ReadSlice('\n')
		if err != nil {
			if err == io.EOF {
				break
			}
			return la, &joe.ReadError{Err: err}
		}
		line++
		for {
			// space delimits the values
			for i, v = range prof.Line[pos:] {
				if v == 0x20 {
					priorPos, pos = pos, pos+i+1
					break
				}
			}
			fieldNum++
			if fieldNum <= 3 {
				f, err = strconv.ParseFloat(string(prof.Line[priorPos:pos-1]), 64)
				if err != nil {
					return la, &joe.ParseError{Info: fmt.Sprintf("line %d: field %d", line, fieldNum), Err: err}
				}
				if fieldNum == 1 {
					la.Minute = float32(f)
					continue
				}
				if fieldNum == 2 {
					la.Five = float32(f)
					continue
				}
				la.Fifteen = float32(f)
				continue
			}
			if fieldNum == 4 {
				// get the process information: separated by /
				for i, v = range prof.Line[priorPos:pos] {
					if v == '/' {
						break
					}
				}
				n, err = helpers.ParseUint(prof.Line[priorPos : priorPos+i])
				if err != nil {
					return la, &joe.ParseError{Info: fmt.Sprintf("line %d: field %d", line, fieldNum), Err: err}
				}
				la.Running = int32(n)
				n, err = helpers.ParseUint(prof.Line[priorPos+i+1 : pos-1])
				if err != nil {
					return la, &joe.ParseError{Info: fmt.Sprintf("line %d: field %d", line, fieldNum), Err: err}
				}
				la.Total = int32(n)
				continue
			}
			n, err = helpers.ParseUint(prof.Line[pos : len(prof.Line)-1])
			if err != nil {
				return la, err
			}
			la.PID = int32(n)
			break
		}
	}
	return la, nil
}
170926
func Get() (os *OS, err error) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std, err = NewProfiler()
		if err != nil {
			return nil, err
		}
	}
	return std.Get()
}
1135690
func (provider *HerokuProvider) GetUser(creds *common.Credentials) (common.User, error) {

	profileData, err := provider.Get(creds, herokuEndpointProfile)

	if err != nil {
		return nil, err
	}

	// build user
	user := NewUser(profileData, creds, provider)

	return user, nil
}
1119751
func (s profileService) FetchProfile(profileUUID string) (*Profile, error) {
	var response Profile
	req, err := s.client.NewRequest("GET", defineProfilePath, nil)
	if err != nil {
		return nil, err
	}
	query := req.URL.Query()
	query.Add("profile_uuid", profileUUID)
	req.URL.RawQuery = query.Encode()
	err = s.client.Do(req, &response)
	if err != nil {
		return nil, err
	}
	return &response, nil
}
778217
func (f FakeGetter) Get(name string) (*api.Service, error) {
	return f.Svc, f.Err
}
573518
func (prof *Profiler) Get() (stats *CPUStats, err error) {
	err = prof.Reset()
	if err != nil {
		return nil, err
	}
	var (
		i, j, pos, fieldNum int
		n                   uint64
		v                   byte
		stop                bool
	)

	stats = &CPUStats{Timestamp: time.Now().UTC().UnixNano(), ClkTck: prof.ClkTck, CPU: make([]CPU, 0, 2)}

	// read each line until eof
	for {
		prof.Line, err = prof.ReadSlice('\n')
		if err != nil {
			if err == io.EOF {
				break
			}
			return nil, &joe.ReadError{Err: err}
		}
		prof.Val = prof.Val[:0]
		// Get everything up to the first space, this is the key.  Not all keys are processed.
		for i, v = range prof.Line {
			if v == 0x20 {
				prof.Val = prof.Line[:i]
				pos = i + 1
				break
			}
		}
		// skip the intr line
		if prof.Val[0] == 'i' {
			continue
		}
		if prof.Val[0] == 'c' {
			if prof.Val[1] == 'p' { // process CPU
				cpu := CPU{ID: string(prof.Val[:])}
				j = 0
				// skip over any remaining spaces
				for i, v = range prof.Line[pos:] {
					if v != 0x20 {
						break
					}
					j++
				}
				fieldNum = 0
				pos, j = j+pos, j+pos
				// space is the field separator
				for i, v = range prof.Line[pos:] {
					if v == '\n' {
						stop = true
					}
					if v == 0x20 || stop {
						fieldNum++
						n, err = helpers.ParseUint(prof.Line[j : pos+i])
						if err != nil {
							return stats, &joe.ParseError{Info: string(prof.Val[:]), Err: err}
						}
						j = pos + i + 1
						if fieldNum < 6 {
							if fieldNum < 4 {
								if fieldNum == 1 {
									cpu.User = int64(n)
									continue
								}
								if fieldNum == 2 {
									cpu.Nice = int64(n)
									continue
								}
								cpu.System = int64(n) // 3
								continue
							}
							if fieldNum == 4 {
								cpu.Idle = int64(n)
								continue
							}
							cpu.IOWait = int64(n) // 5
							continue
						}
						if fieldNum < 8 {
							if fieldNum == 6 {
								cpu.IRQ = int64(n)
								continue
							}
							cpu.SoftIRQ = int64(n) // 7
							continue
						}
						if fieldNum == 8 {
							cpu.Steal = int64(n)
							continue
						}
						if fieldNum == 9 {
							cpu.Quest = int64(n)
							continue
						}
						cpu.QuestNice = int64(n) // 10
					}
				}
				stats.CPU = append(stats.CPU, cpu)
				stop = false
				continue
			}
			// Otherwise it's ctxt info; rest of the line is the data.
			n, err = helpers.ParseUint(prof.Line[pos : len(prof.Line)-1])
			if err != nil {
				return stats, &joe.ParseError{Info: string(prof.Val[:]), Err: err}
			}
			stats.Ctxt = int64(n)
			continue
		}
		if prof.Val[0] == 'b' {
			// rest of the line is the data
			n, err = helpers.ParseUint(prof.Line[pos : len(prof.Line)-1])
			if err != nil {
				return stats, &joe.ParseError{Info: string(prof.Val[:]), Err: err}
			}
			stats.BTime = int64(n)
			continue
		}
		if prof.Val[0] == 'p' && prof.Val[4] == 'e' { // processes info
			// rest of the line is the data
			n, err = helpers.ParseUint(prof.Line[pos : len(prof.Line)-1])
			if err != nil {
				return stats, &joe.ParseError{Info: string(prof.Val[:]), Err: err}
			}
			stats.Processes = int64(n)
			continue
		}
	}
	return stats, nil
}