repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
google/pprof | internal/symbolizer/symbolizer.go | Symbolize | func (s *Symbolizer) Symbolize(mode string, sources plugin.MappingSources, p *profile.Profile) error {
remote, local, fast, force, demanglerMode := true, true, false, false, ""
for _, o := range strings.Split(strings.ToLower(mode), ":") {
switch o {
case "":
continue
case "none", "no":
return nil
case "... | go | func (s *Symbolizer) Symbolize(mode string, sources plugin.MappingSources, p *profile.Profile) error {
remote, local, fast, force, demanglerMode := true, true, false, false, ""
for _, o := range strings.Split(strings.ToLower(mode), ":") {
switch o {
case "":
continue
case "none", "no":
return nil
case "... | [
"func",
"(",
"s",
"*",
"Symbolizer",
")",
"Symbolize",
"(",
"mode",
"string",
",",
"sources",
"plugin",
".",
"MappingSources",
",",
"p",
"*",
"profile",
".",
"Profile",
")",
"error",
"{",
"remote",
",",
"local",
",",
"fast",
",",
"force",
",",
"demangl... | // Symbolize attempts to symbolize profile p. First uses binutils on
// local binaries; if the source is a URL it attempts to get any
// missed entries using symbolz. | [
"Symbolize",
"attempts",
"to",
"symbolize",
"profile",
"p",
".",
"First",
"uses",
"binutils",
"on",
"local",
"binaries",
";",
"if",
"the",
"source",
"is",
"a",
"URL",
"it",
"attempts",
"to",
"get",
"any",
"missed",
"entries",
"using",
"symbolz",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/symbolizer/symbolizer.go#L50-L98 | train |
google/pprof | internal/symbolizer/symbolizer.go | postURL | func postURL(source, post string, tr http.RoundTripper) ([]byte, error) {
client := &http.Client{
Transport: tr,
}
resp, err := client.Post(source, "application/octet-stream", strings.NewReader(post))
if err != nil {
return nil, fmt.Errorf("http post %s: %v", source, err)
}
defer resp.Body.Close()
if resp.St... | go | func postURL(source, post string, tr http.RoundTripper) ([]byte, error) {
client := &http.Client{
Transport: tr,
}
resp, err := client.Post(source, "application/octet-stream", strings.NewReader(post))
if err != nil {
return nil, fmt.Errorf("http post %s: %v", source, err)
}
defer resp.Body.Close()
if resp.St... | [
"func",
"postURL",
"(",
"source",
",",
"post",
"string",
",",
"tr",
"http",
".",
"RoundTripper",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"client",
":=",
"&",
"http",
".",
"Client",
"{",
"Transport",
":",
"tr",
",",
"}",
"\n",
"resp",
... | // postURL issues a POST to a URL over HTTP. | [
"postURL",
"issues",
"a",
"POST",
"to",
"a",
"URL",
"over",
"HTTP",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/symbolizer/symbolizer.go#L101-L114 | train |
google/pprof | internal/symbolizer/symbolizer.go | doLocalSymbolize | func doLocalSymbolize(prof *profile.Profile, fast, force bool, obj plugin.ObjTool, ui plugin.UI) error {
if fast {
if bu, ok := obj.(*binutils.Binutils); ok {
bu.SetFastSymbolization(true)
}
}
mt, err := newMapping(prof, obj, ui, force)
if err != nil {
return err
}
defer mt.close()
functions := make(m... | go | func doLocalSymbolize(prof *profile.Profile, fast, force bool, obj plugin.ObjTool, ui plugin.UI) error {
if fast {
if bu, ok := obj.(*binutils.Binutils); ok {
bu.SetFastSymbolization(true)
}
}
mt, err := newMapping(prof, obj, ui, force)
if err != nil {
return err
}
defer mt.close()
functions := make(m... | [
"func",
"doLocalSymbolize",
"(",
"prof",
"*",
"profile",
".",
"Profile",
",",
"fast",
",",
"force",
"bool",
",",
"obj",
"plugin",
".",
"ObjTool",
",",
"ui",
"plugin",
".",
"UI",
")",
"error",
"{",
"if",
"fast",
"{",
"if",
"bu",
",",
"ok",
":=",
"ob... | // doLocalSymbolize adds symbol and line number information to all locations
// in a profile. mode enables some options to control
// symbolization. | [
"doLocalSymbolize",
"adds",
"symbol",
"and",
"line",
"number",
"information",
"to",
"all",
"locations",
"in",
"a",
"profile",
".",
"mode",
"enables",
"some",
"options",
"to",
"control",
"symbolization",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/symbolizer/symbolizer.go#L129-L193 | train |
google/pprof | internal/symbolizer/symbolizer.go | Demangle | func Demangle(prof *profile.Profile, force bool, demanglerMode string) {
if force {
// Remove the current demangled names to force demangling
for _, f := range prof.Function {
if f.Name != "" && f.SystemName != "" {
f.Name = f.SystemName
}
}
}
var options []demangle.Option
switch demanglerMode {
c... | go | func Demangle(prof *profile.Profile, force bool, demanglerMode string) {
if force {
// Remove the current demangled names to force demangling
for _, f := range prof.Function {
if f.Name != "" && f.SystemName != "" {
f.Name = f.SystemName
}
}
}
var options []demangle.Option
switch demanglerMode {
c... | [
"func",
"Demangle",
"(",
"prof",
"*",
"profile",
".",
"Profile",
",",
"force",
"bool",
",",
"demanglerMode",
"string",
")",
"{",
"if",
"force",
"{",
"// Remove the current demangled names to force demangling",
"for",
"_",
",",
"f",
":=",
"range",
"prof",
".",
... | // Demangle updates the function names in a profile with demangled C++
// names, simplified according to demanglerMode. If force is set,
// overwrite any names that appear already demangled. | [
"Demangle",
"updates",
"the",
"function",
"names",
"in",
"a",
"profile",
"with",
"demangled",
"C",
"++",
"names",
"simplified",
"according",
"to",
"demanglerMode",
".",
"If",
"force",
"is",
"set",
"overwrite",
"any",
"names",
"that",
"appear",
"already",
"dema... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/symbolizer/symbolizer.go#L198-L244 | train |
google/pprof | internal/symbolizer/symbolizer.go | looksLikeDemangledCPlusPlus | func looksLikeDemangledCPlusPlus(demangled string) bool {
if strings.Contains(demangled, ".<") { // Skip java names of the form "class.<init>"
return false
}
return strings.ContainsAny(demangled, "<>[]") || strings.Contains(demangled, "::")
} | go | func looksLikeDemangledCPlusPlus(demangled string) bool {
if strings.Contains(demangled, ".<") { // Skip java names of the form "class.<init>"
return false
}
return strings.ContainsAny(demangled, "<>[]") || strings.Contains(demangled, "::")
} | [
"func",
"looksLikeDemangledCPlusPlus",
"(",
"demangled",
"string",
")",
"bool",
"{",
"if",
"strings",
".",
"Contains",
"(",
"demangled",
",",
"\"",
"\"",
")",
"{",
"// Skip java names of the form \"class.<init>\"",
"return",
"false",
"\n",
"}",
"\n",
"return",
"st... | // looksLikeDemangledCPlusPlus is a heuristic to decide if a name is
// the result of demangling C++. If so, further heuristics will be
// applied to simplify the name. | [
"looksLikeDemangledCPlusPlus",
"is",
"a",
"heuristic",
"to",
"decide",
"if",
"a",
"name",
"is",
"the",
"result",
"of",
"demangling",
"C",
"++",
".",
"If",
"so",
"further",
"heuristics",
"will",
"be",
"applied",
"to",
"simplify",
"the",
"name",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/symbolizer/symbolizer.go#L249-L254 | train |
google/pprof | internal/symbolizer/symbolizer.go | removeMatching | func removeMatching(name string, start, end byte) string {
s := string(start) + string(end)
var nesting, first, current int
for index := strings.IndexAny(name[current:], s); index != -1; index = strings.IndexAny(name[current:], s) {
switch current += index; name[current] {
case start:
nesting++
if nesting ... | go | func removeMatching(name string, start, end byte) string {
s := string(start) + string(end)
var nesting, first, current int
for index := strings.IndexAny(name[current:], s); index != -1; index = strings.IndexAny(name[current:], s) {
switch current += index; name[current] {
case start:
nesting++
if nesting ... | [
"func",
"removeMatching",
"(",
"name",
"string",
",",
"start",
",",
"end",
"byte",
")",
"string",
"{",
"s",
":=",
"string",
"(",
"start",
")",
"+",
"string",
"(",
"end",
")",
"\n",
"var",
"nesting",
",",
"first",
",",
"current",
"int",
"\n",
"for",
... | // removeMatching removes nested instances of start..end from name. | [
"removeMatching",
"removes",
"nested",
"instances",
"of",
"start",
"..",
"end",
"from",
"name",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/symbolizer/symbolizer.go#L257-L280 | train |
google/pprof | internal/driver/commands.go | help | func (c *command) help(name string) string {
message := c.description + "\n"
if c.usage != "" {
message += " Usage:\n"
lines := strings.Split(c.usage, "\n")
for _, line := range lines {
message += fmt.Sprintf(" %s\n", line)
}
}
return message + "\n"
} | go | func (c *command) help(name string) string {
message := c.description + "\n"
if c.usage != "" {
message += " Usage:\n"
lines := strings.Split(c.usage, "\n")
for _, line := range lines {
message += fmt.Sprintf(" %s\n", line)
}
}
return message + "\n"
} | [
"func",
"(",
"c",
"*",
"command",
")",
"help",
"(",
"name",
"string",
")",
"string",
"{",
"message",
":=",
"c",
".",
"description",
"+",
"\"",
"\\n",
"\"",
"\n",
"if",
"c",
".",
"usage",
"!=",
"\"",
"\"",
"{",
"message",
"+=",
"\"",
"\\n",
"\"",
... | // help returns a help string for a command. | [
"help",
"returns",
"a",
"help",
"string",
"for",
"a",
"command",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/commands.go#L50-L60 | train |
google/pprof | internal/driver/commands.go | AddCommand | func AddCommand(cmd string, format int, post PostProcessor, desc, usage string) {
pprofCommands[cmd] = &command{format, post, nil, false, desc, usage}
} | go | func AddCommand(cmd string, format int, post PostProcessor, desc, usage string) {
pprofCommands[cmd] = &command{format, post, nil, false, desc, usage}
} | [
"func",
"AddCommand",
"(",
"cmd",
"string",
",",
"format",
"int",
",",
"post",
"PostProcessor",
",",
"desc",
",",
"usage",
"string",
")",
"{",
"pprofCommands",
"[",
"cmd",
"]",
"=",
"&",
"command",
"{",
"format",
",",
"post",
",",
"nil",
",",
"false",
... | // AddCommand adds an additional command to the set of commands
// accepted by pprof. This enables extensions to add new commands for
// specialized visualization formats. If the command specified already
// exists, it is overwritten. | [
"AddCommand",
"adds",
"an",
"additional",
"command",
"to",
"the",
"set",
"of",
"commands",
"accepted",
"by",
"pprof",
".",
"This",
"enables",
"extensions",
"to",
"add",
"new",
"commands",
"for",
"specialized",
"visualization",
"formats",
".",
"If",
"the",
"com... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/commands.go#L66-L68 | train |
google/pprof | internal/driver/commands.go | SetVariableDefault | func SetVariableDefault(variable, value string) {
if v := pprofVariables[variable]; v != nil {
v.value = value
}
} | go | func SetVariableDefault(variable, value string) {
if v := pprofVariables[variable]; v != nil {
v.value = value
}
} | [
"func",
"SetVariableDefault",
"(",
"variable",
",",
"value",
"string",
")",
"{",
"if",
"v",
":=",
"pprofVariables",
"[",
"variable",
"]",
";",
"v",
"!=",
"nil",
"{",
"v",
".",
"value",
"=",
"value",
"\n",
"}",
"\n",
"}"
] | // SetVariableDefault sets the default value for a pprof
// variable. This enables extensions to set their own defaults. | [
"SetVariableDefault",
"sets",
"the",
"default",
"value",
"for",
"a",
"pprof",
"variable",
".",
"This",
"enables",
"extensions",
"to",
"set",
"their",
"own",
"defaults",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/commands.go#L72-L76 | train |
google/pprof | internal/driver/commands.go | usage | func usage(commandLine bool) string {
var prefix string
if commandLine {
prefix = "-"
}
fmtHelp := func(c, d string) string {
return fmt.Sprintf(" %-16s %s", c, strings.SplitN(d, "\n", 2)[0])
}
var commands []string
for name, cmd := range pprofCommands {
commands = append(commands, fmtHelp(prefix+name,... | go | func usage(commandLine bool) string {
var prefix string
if commandLine {
prefix = "-"
}
fmtHelp := func(c, d string) string {
return fmt.Sprintf(" %-16s %s", c, strings.SplitN(d, "\n", 2)[0])
}
var commands []string
for name, cmd := range pprofCommands {
commands = append(commands, fmtHelp(prefix+name,... | [
"func",
"usage",
"(",
"commandLine",
"bool",
")",
"string",
"{",
"var",
"prefix",
"string",
"\n",
"if",
"commandLine",
"{",
"prefix",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"fmtHelp",
":=",
"func",
"(",
"c",
",",
"d",
"string",
")",
"string",
"{",
"return... | // usage returns a string describing the pprof commands and variables.
// if commandLine is set, the output reflect cli usage. | [
"usage",
"returns",
"a",
"string",
"describing",
"the",
"pprof",
"commands",
"and",
"variables",
".",
"if",
"commandLine",
"is",
"set",
"the",
"output",
"reflect",
"cli",
"usage",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/commands.go#L251-L306 | train |
google/pprof | internal/driver/commands.go | browsers | func browsers() []string {
var cmds []string
if userBrowser := os.Getenv("BROWSER"); userBrowser != "" {
cmds = append(cmds, userBrowser)
}
switch runtime.GOOS {
case "darwin":
cmds = append(cmds, "/usr/bin/open")
case "windows":
cmds = append(cmds, "cmd /c start")
default:
// Commands opening browsers a... | go | func browsers() []string {
var cmds []string
if userBrowser := os.Getenv("BROWSER"); userBrowser != "" {
cmds = append(cmds, userBrowser)
}
switch runtime.GOOS {
case "darwin":
cmds = append(cmds, "/usr/bin/open")
case "windows":
cmds = append(cmds, "cmd /c start")
default:
// Commands opening browsers a... | [
"func",
"browsers",
"(",
")",
"[",
"]",
"string",
"{",
"var",
"cmds",
"[",
"]",
"string",
"\n",
"if",
"userBrowser",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
";",
"userBrowser",
"!=",
"\"",
"\"",
"{",
"cmds",
"=",
"append",
"(",
"cmds",
"... | // browsers returns a list of commands to attempt for web visualization. | [
"browsers",
"returns",
"a",
"list",
"of",
"commands",
"to",
"attempt",
"for",
"web",
"visualization",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/commands.go#L339-L361 | train |
google/pprof | internal/driver/commands.go | massageDotSVG | func massageDotSVG() PostProcessor {
generateSVG := invokeDot("svg")
return func(input io.Reader, output io.Writer, ui plugin.UI) error {
baseSVG := new(bytes.Buffer)
if err := generateSVG(input, baseSVG, ui); err != nil {
return err
}
_, err := output.Write([]byte(massageSVG(baseSVG.String())))
return e... | go | func massageDotSVG() PostProcessor {
generateSVG := invokeDot("svg")
return func(input io.Reader, output io.Writer, ui plugin.UI) error {
baseSVG := new(bytes.Buffer)
if err := generateSVG(input, baseSVG, ui); err != nil {
return err
}
_, err := output.Write([]byte(massageSVG(baseSVG.String())))
return e... | [
"func",
"massageDotSVG",
"(",
")",
"PostProcessor",
"{",
"generateSVG",
":=",
"invokeDot",
"(",
"\"",
"\"",
")",
"\n",
"return",
"func",
"(",
"input",
"io",
".",
"Reader",
",",
"output",
"io",
".",
"Writer",
",",
"ui",
"plugin",
".",
"UI",
")",
"error"... | // massageDotSVG invokes the dot tool to generate an SVG image and alters
// the image to have panning capabilities when viewed in a browser. | [
"massageDotSVG",
"invokes",
"the",
"dot",
"tool",
"to",
"generate",
"an",
"SVG",
"image",
"and",
"alters",
"the",
"image",
"to",
"have",
"panning",
"capabilities",
"when",
"viewed",
"in",
"a",
"browser",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/commands.go#L396-L406 | train |
google/pprof | internal/driver/commands.go | set | func (vars variables) set(name, value string) error {
v := vars[name]
if v == nil {
return fmt.Errorf("no variable %s", name)
}
var err error
switch v.kind {
case boolKind:
var b bool
if b, err = stringToBool(value); err == nil {
if v.group != "" && !b {
err = fmt.Errorf("%q can only be set to true",... | go | func (vars variables) set(name, value string) error {
v := vars[name]
if v == nil {
return fmt.Errorf("no variable %s", name)
}
var err error
switch v.kind {
case boolKind:
var b bool
if b, err = stringToBool(value); err == nil {
if v.group != "" && !b {
err = fmt.Errorf("%q can only be set to true",... | [
"func",
"(",
"vars",
"variables",
")",
"set",
"(",
"name",
",",
"value",
"string",
")",
"error",
"{",
"v",
":=",
"vars",
"[",
"name",
"]",
"\n",
"if",
"v",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"name",
")",
"\n... | // set updates the value of a variable, checking that the value is
// suitable for the variable Kind. | [
"set",
"updates",
"the",
"value",
"of",
"a",
"variable",
"checking",
"that",
"the",
"value",
"is",
"suitable",
"for",
"the",
"variable",
"Kind",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/commands.go#L469-L505 | train |
google/pprof | internal/driver/commands.go | boolValue | func (v *variable) boolValue() bool {
b, err := stringToBool(v.value)
if err != nil {
panic("unexpected value " + v.value + " for bool ")
}
return b
} | go | func (v *variable) boolValue() bool {
b, err := stringToBool(v.value)
if err != nil {
panic("unexpected value " + v.value + " for bool ")
}
return b
} | [
"func",
"(",
"v",
"*",
"variable",
")",
"boolValue",
"(",
")",
"bool",
"{",
"b",
",",
"err",
":=",
"stringToBool",
"(",
"v",
".",
"value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
"+",
"v",
".",
"value",
"+",
"\"",
... | // boolValue returns the value of a boolean variable. | [
"boolValue",
"returns",
"the",
"value",
"of",
"a",
"boolean",
"variable",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/commands.go#L508-L514 | train |
google/pprof | internal/driver/commands.go | intValue | func (v *variable) intValue() int {
i, err := strconv.Atoi(v.value)
if err != nil {
panic("unexpected value " + v.value + " for int ")
}
return i
} | go | func (v *variable) intValue() int {
i, err := strconv.Atoi(v.value)
if err != nil {
panic("unexpected value " + v.value + " for int ")
}
return i
} | [
"func",
"(",
"v",
"*",
"variable",
")",
"intValue",
"(",
")",
"int",
"{",
"i",
",",
"err",
":=",
"strconv",
".",
"Atoi",
"(",
"v",
".",
"value",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
"+",
"v",
".",
"value",
"+",
... | // intValue returns the value of an intKind variable. | [
"intValue",
"returns",
"the",
"value",
"of",
"an",
"intKind",
"variable",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/commands.go#L517-L523 | train |
google/pprof | internal/driver/commands.go | floatValue | func (v *variable) floatValue() float64 {
f, err := strconv.ParseFloat(v.value, 64)
if err != nil {
panic("unexpected value " + v.value + " for float ")
}
return f
} | go | func (v *variable) floatValue() float64 {
f, err := strconv.ParseFloat(v.value, 64)
if err != nil {
panic("unexpected value " + v.value + " for float ")
}
return f
} | [
"func",
"(",
"v",
"*",
"variable",
")",
"floatValue",
"(",
")",
"float64",
"{",
"f",
",",
"err",
":=",
"strconv",
".",
"ParseFloat",
"(",
"v",
".",
"value",
",",
"64",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
"+",
"v"... | // floatValue returns the value of a Float variable. | [
"floatValue",
"returns",
"the",
"value",
"of",
"a",
"Float",
"variable",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/commands.go#L526-L532 | train |
google/pprof | internal/driver/commands.go | stringValue | func (v *variable) stringValue() string {
switch v.kind {
case boolKind:
return fmt.Sprint(v.boolValue())
case intKind:
return fmt.Sprint(v.intValue())
case floatKind:
return fmt.Sprint(v.floatValue())
}
return v.value
} | go | func (v *variable) stringValue() string {
switch v.kind {
case boolKind:
return fmt.Sprint(v.boolValue())
case intKind:
return fmt.Sprint(v.intValue())
case floatKind:
return fmt.Sprint(v.floatValue())
}
return v.value
} | [
"func",
"(",
"v",
"*",
"variable",
")",
"stringValue",
"(",
")",
"string",
"{",
"switch",
"v",
".",
"kind",
"{",
"case",
"boolKind",
":",
"return",
"fmt",
".",
"Sprint",
"(",
"v",
".",
"boolValue",
"(",
")",
")",
"\n",
"case",
"intKind",
":",
"retu... | // stringValue returns a canonical representation for a variable. | [
"stringValue",
"returns",
"a",
"canonical",
"representation",
"for",
"a",
"variable",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/commands.go#L535-L545 | train |
google/pprof | internal/driver/commands.go | makeCopy | func (vars variables) makeCopy() variables {
varscopy := make(variables, len(vars))
for n, v := range vars {
vcopy := *v
varscopy[n] = &vcopy
}
return varscopy
} | go | func (vars variables) makeCopy() variables {
varscopy := make(variables, len(vars))
for n, v := range vars {
vcopy := *v
varscopy[n] = &vcopy
}
return varscopy
} | [
"func",
"(",
"vars",
"variables",
")",
"makeCopy",
"(",
")",
"variables",
"{",
"varscopy",
":=",
"make",
"(",
"variables",
",",
"len",
"(",
"vars",
")",
")",
"\n",
"for",
"n",
",",
"v",
":=",
"range",
"vars",
"{",
"vcopy",
":=",
"*",
"v",
"\n",
"... | // makeCopy returns a duplicate of a set of shell variables. | [
"makeCopy",
"returns",
"a",
"duplicate",
"of",
"a",
"set",
"of",
"shell",
"variables",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/commands.go#L559-L566 | train |
google/pprof | internal/driver/fetch.go | chunkedGrab | func chunkedGrab(sources []profileSource, fetch plugin.Fetcher, obj plugin.ObjTool, ui plugin.UI, tr http.RoundTripper) (*profile.Profile, plugin.MappingSources, bool, int, error) {
const chunkSize = 64
var p *profile.Profile
var msrc plugin.MappingSources
var save bool
var count int
for start := 0; start < len... | go | func chunkedGrab(sources []profileSource, fetch plugin.Fetcher, obj plugin.ObjTool, ui plugin.UI, tr http.RoundTripper) (*profile.Profile, plugin.MappingSources, bool, int, error) {
const chunkSize = 64
var p *profile.Profile
var msrc plugin.MappingSources
var save bool
var count int
for start := 0; start < len... | [
"func",
"chunkedGrab",
"(",
"sources",
"[",
"]",
"profileSource",
",",
"fetch",
"plugin",
".",
"Fetcher",
",",
"obj",
"plugin",
".",
"ObjTool",
",",
"ui",
"plugin",
".",
"UI",
",",
"tr",
"http",
".",
"RoundTripper",
")",
"(",
"*",
"profile",
".",
"Prof... | // chunkedGrab fetches the profiles described in source and merges them into
// a single profile. It fetches a chunk of profiles concurrently, with a maximum
// chunk size to limit its memory usage. | [
"chunkedGrab",
"fetches",
"the",
"profiles",
"described",
"in",
"source",
"and",
"merges",
"them",
"into",
"a",
"single",
"profile",
".",
"It",
"fetches",
"a",
"chunk",
"of",
"profiles",
"concurrently",
"with",
"a",
"maximum",
"chunk",
"size",
"to",
"limit",
... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/fetch.go#L169-L203 | train |
google/pprof | internal/driver/fetch.go | concurrentGrab | func concurrentGrab(sources []profileSource, fetch plugin.Fetcher, obj plugin.ObjTool, ui plugin.UI, tr http.RoundTripper) (*profile.Profile, plugin.MappingSources, bool, int, error) {
wg := sync.WaitGroup{}
wg.Add(len(sources))
for i := range sources {
go func(s *profileSource) {
defer wg.Done()
s.p, s.msrc... | go | func concurrentGrab(sources []profileSource, fetch plugin.Fetcher, obj plugin.ObjTool, ui plugin.UI, tr http.RoundTripper) (*profile.Profile, plugin.MappingSources, bool, int, error) {
wg := sync.WaitGroup{}
wg.Add(len(sources))
for i := range sources {
go func(s *profileSource) {
defer wg.Done()
s.p, s.msrc... | [
"func",
"concurrentGrab",
"(",
"sources",
"[",
"]",
"profileSource",
",",
"fetch",
"plugin",
".",
"Fetcher",
",",
"obj",
"plugin",
".",
"ObjTool",
",",
"ui",
"plugin",
".",
"UI",
",",
"tr",
"http",
".",
"RoundTripper",
")",
"(",
"*",
"profile",
".",
"P... | // concurrentGrab fetches multiple profiles concurrently | [
"concurrentGrab",
"fetches",
"multiple",
"profiles",
"concurrently"
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/fetch.go#L206-L241 | train |
google/pprof | internal/driver/fetch.go | grabProfile | func grabProfile(s *source, source string, fetcher plugin.Fetcher, obj plugin.ObjTool, ui plugin.UI, tr http.RoundTripper) (p *profile.Profile, msrc plugin.MappingSources, remote bool, err error) {
var src string
duration, timeout := time.Duration(s.Seconds)*time.Second, time.Duration(s.Timeout)*time.Second
if fetch... | go | func grabProfile(s *source, source string, fetcher plugin.Fetcher, obj plugin.ObjTool, ui plugin.UI, tr http.RoundTripper) (p *profile.Profile, msrc plugin.MappingSources, remote bool, err error) {
var src string
duration, timeout := time.Duration(s.Seconds)*time.Second, time.Duration(s.Timeout)*time.Second
if fetch... | [
"func",
"grabProfile",
"(",
"s",
"*",
"source",
",",
"source",
"string",
",",
"fetcher",
"plugin",
".",
"Fetcher",
",",
"obj",
"plugin",
".",
"ObjTool",
",",
"ui",
"plugin",
".",
"UI",
",",
"tr",
"http",
".",
"RoundTripper",
")",
"(",
"p",
"*",
"prof... | // grabProfile fetches a profile. Returns the profile, sources for the
// profile mappings, a bool indicating if the profile was fetched
// remotely, and an error. | [
"grabProfile",
"fetches",
"a",
"profile",
".",
"Returns",
"the",
"profile",
"sources",
"for",
"the",
"profile",
"mappings",
"a",
"bool",
"indicating",
"if",
"the",
"profile",
"was",
"fetched",
"remotely",
"and",
"an",
"error",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/fetch.go#L312-L347 | train |
google/pprof | internal/driver/fetch.go | collectMappingSources | func collectMappingSources(p *profile.Profile, source string) plugin.MappingSources {
ms := plugin.MappingSources{}
for _, m := range p.Mapping {
src := struct {
Source string
Start uint64
}{
source, m.Start,
}
key := m.BuildID
if key == "" {
key = m.File
}
if key == "" {
// If there is ... | go | func collectMappingSources(p *profile.Profile, source string) plugin.MappingSources {
ms := plugin.MappingSources{}
for _, m := range p.Mapping {
src := struct {
Source string
Start uint64
}{
source, m.Start,
}
key := m.BuildID
if key == "" {
key = m.File
}
if key == "" {
// If there is ... | [
"func",
"collectMappingSources",
"(",
"p",
"*",
"profile",
".",
"Profile",
",",
"source",
"string",
")",
"plugin",
".",
"MappingSources",
"{",
"ms",
":=",
"plugin",
".",
"MappingSources",
"{",
"}",
"\n",
"for",
"_",
",",
"m",
":=",
"range",
"p",
".",
"... | // collectMappingSources saves the mapping sources of a profile. | [
"collectMappingSources",
"saves",
"the",
"mapping",
"sources",
"of",
"a",
"profile",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/fetch.go#L350-L375 | train |
google/pprof | internal/driver/fetch.go | unsourceMappings | func unsourceMappings(p *profile.Profile) {
for _, m := range p.Mapping {
if m.BuildID == "" {
if u, err := url.Parse(m.File); err == nil && u.IsAbs() {
m.File = ""
}
}
}
} | go | func unsourceMappings(p *profile.Profile) {
for _, m := range p.Mapping {
if m.BuildID == "" {
if u, err := url.Parse(m.File); err == nil && u.IsAbs() {
m.File = ""
}
}
}
} | [
"func",
"unsourceMappings",
"(",
"p",
"*",
"profile",
".",
"Profile",
")",
"{",
"for",
"_",
",",
"m",
":=",
"range",
"p",
".",
"Mapping",
"{",
"if",
"m",
".",
"BuildID",
"==",
"\"",
"\"",
"{",
"if",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"... | // unsourceMappings iterates over the mappings in a profile and replaces file
// set to the remote source URL by collectMappingSources back to empty string. | [
"unsourceMappings",
"iterates",
"over",
"the",
"mappings",
"in",
"a",
"profile",
"and",
"replaces",
"file",
"set",
"to",
"the",
"remote",
"source",
"URL",
"by",
"collectMappingSources",
"back",
"to",
"empty",
"string",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/fetch.go#L379-L387 | train |
google/pprof | internal/driver/fetch.go | locateBinaries | func locateBinaries(p *profile.Profile, s *source, obj plugin.ObjTool, ui plugin.UI) {
// Construct search path to examine
searchPath := os.Getenv("PPROF_BINARY_PATH")
if searchPath == "" {
// Use $HOME/pprof/binaries as default directory for local symbolization binaries
searchPath = filepath.Join(os.Getenv(home... | go | func locateBinaries(p *profile.Profile, s *source, obj plugin.ObjTool, ui plugin.UI) {
// Construct search path to examine
searchPath := os.Getenv("PPROF_BINARY_PATH")
if searchPath == "" {
// Use $HOME/pprof/binaries as default directory for local symbolization binaries
searchPath = filepath.Join(os.Getenv(home... | [
"func",
"locateBinaries",
"(",
"p",
"*",
"profile",
".",
"Profile",
",",
"s",
"*",
"source",
",",
"obj",
"plugin",
".",
"ObjTool",
",",
"ui",
"plugin",
".",
"UI",
")",
"{",
"// Construct search path to examine",
"searchPath",
":=",
"os",
".",
"Getenv",
"("... | // locateBinaries searches for binary files listed in the profile and, if found,
// updates the profile accordingly. | [
"locateBinaries",
"searches",
"for",
"binary",
"files",
"listed",
"in",
"the",
"profile",
"and",
"if",
"found",
"updates",
"the",
"profile",
"accordingly",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/fetch.go#L391-L458 | train |
google/pprof | internal/driver/fetch.go | fetch | func fetch(source string, duration, timeout time.Duration, ui plugin.UI, tr http.RoundTripper) (p *profile.Profile, src string, err error) {
var f io.ReadCloser
if sourceURL, timeout := adjustURL(source, duration, timeout); sourceURL != "" {
ui.Print("Fetching profile over HTTP from " + sourceURL)
if duration > ... | go | func fetch(source string, duration, timeout time.Duration, ui plugin.UI, tr http.RoundTripper) (p *profile.Profile, src string, err error) {
var f io.ReadCloser
if sourceURL, timeout := adjustURL(source, duration, timeout); sourceURL != "" {
ui.Print("Fetching profile over HTTP from " + sourceURL)
if duration > ... | [
"func",
"fetch",
"(",
"source",
"string",
",",
"duration",
",",
"timeout",
"time",
".",
"Duration",
",",
"ui",
"plugin",
".",
"UI",
",",
"tr",
"http",
".",
"RoundTripper",
")",
"(",
"p",
"*",
"profile",
".",
"Profile",
",",
"src",
"string",
",",
"err... | // fetch fetches a profile from source, within the timeout specified,
// producing messages through the ui. It returns the profile and the
// url of the actual source of the profile for remote profiles. | [
"fetch",
"fetches",
"a",
"profile",
"from",
"source",
"within",
"the",
"timeout",
"specified",
"producing",
"messages",
"through",
"the",
"ui",
".",
"It",
"returns",
"the",
"profile",
"and",
"the",
"url",
"of",
"the",
"actual",
"source",
"of",
"the",
"profil... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/fetch.go#L463-L483 | train |
google/pprof | internal/driver/fetch.go | fetchURL | func fetchURL(source string, timeout time.Duration, tr http.RoundTripper) (io.ReadCloser, error) {
client := &http.Client{
Transport: tr,
Timeout: timeout + 5*time.Second,
}
resp, err := client.Get(source)
if err != nil {
return nil, fmt.Errorf("http fetch: %v", err)
}
if resp.StatusCode != http.StatusOK ... | go | func fetchURL(source string, timeout time.Duration, tr http.RoundTripper) (io.ReadCloser, error) {
client := &http.Client{
Transport: tr,
Timeout: timeout + 5*time.Second,
}
resp, err := client.Get(source)
if err != nil {
return nil, fmt.Errorf("http fetch: %v", err)
}
if resp.StatusCode != http.StatusOK ... | [
"func",
"fetchURL",
"(",
"source",
"string",
",",
"timeout",
"time",
".",
"Duration",
",",
"tr",
"http",
".",
"RoundTripper",
")",
"(",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"client",
":=",
"&",
"http",
".",
"Client",
"{",
"Transport",
":",
... | // fetchURL fetches a profile from a URL using HTTP. | [
"fetchURL",
"fetches",
"a",
"profile",
"from",
"a",
"URL",
"using",
"HTTP",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/fetch.go#L486-L501 | train |
google/pprof | internal/driver/fetch.go | isPerfFile | func isPerfFile(path string) bool {
sourceFile, openErr := os.Open(path)
if openErr != nil {
return false
}
defer sourceFile.Close()
// If the file is the output of a perf record command, it should begin
// with the string PERFILE2.
perfHeader := []byte("PERFILE2")
actualHeader := make([]byte, len(perfHeader... | go | func isPerfFile(path string) bool {
sourceFile, openErr := os.Open(path)
if openErr != nil {
return false
}
defer sourceFile.Close()
// If the file is the output of a perf record command, it should begin
// with the string PERFILE2.
perfHeader := []byte("PERFILE2")
actualHeader := make([]byte, len(perfHeader... | [
"func",
"isPerfFile",
"(",
"path",
"string",
")",
"bool",
"{",
"sourceFile",
",",
"openErr",
":=",
"os",
".",
"Open",
"(",
"path",
")",
"\n",
"if",
"openErr",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"defer",
"sourceFile",
".",
"Close",
... | // isPerfFile checks if a file is in perf.data format. It also returns false
// if it encounters an error during the check. | [
"isPerfFile",
"checks",
"if",
"a",
"file",
"is",
"in",
"perf",
".",
"data",
"format",
".",
"It",
"also",
"returns",
"false",
"if",
"it",
"encounters",
"an",
"error",
"during",
"the",
"check",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/fetch.go#L515-L530 | train |
google/pprof | internal/driver/fetch.go | convertPerfData | func convertPerfData(perfPath string, ui plugin.UI) (*os.File, error) {
ui.Print(fmt.Sprintf(
"Converting %s to a profile.proto... (May take a few minutes)",
perfPath))
profile, err := newTempFile(os.TempDir(), "pprof_", ".pb.gz")
if err != nil {
return nil, err
}
deferDeleteTempFile(profile.Name())
cmd := ... | go | func convertPerfData(perfPath string, ui plugin.UI) (*os.File, error) {
ui.Print(fmt.Sprintf(
"Converting %s to a profile.proto... (May take a few minutes)",
perfPath))
profile, err := newTempFile(os.TempDir(), "pprof_", ".pb.gz")
if err != nil {
return nil, err
}
deferDeleteTempFile(profile.Name())
cmd := ... | [
"func",
"convertPerfData",
"(",
"perfPath",
"string",
",",
"ui",
"plugin",
".",
"UI",
")",
"(",
"*",
"os",
".",
"File",
",",
"error",
")",
"{",
"ui",
".",
"Print",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"perfPath",
")",
")",
"\n",
"pro... | // convertPerfData converts the file at path which should be in perf.data format
// using the perf_to_profile tool and returns the file containing the
// profile.proto formatted data. | [
"convertPerfData",
"converts",
"the",
"file",
"at",
"path",
"which",
"should",
"be",
"in",
"perf",
".",
"data",
"format",
"using",
"the",
"perf_to_profile",
"tool",
"and",
"returns",
"the",
"file",
"containing",
"the",
"profile",
".",
"proto",
"formatted",
"da... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/fetch.go#L535-L551 | train |
google/pprof | internal/driver/fetch.go | adjustURL | func adjustURL(source string, duration, timeout time.Duration) (string, time.Duration) {
u, err := url.Parse(source)
if err != nil || (u.Host == "" && u.Scheme != "" && u.Scheme != "file") {
// Try adding http:// to catch sources of the form hostname:port/path.
// url.Parse treats "hostname" as the scheme.
u, e... | go | func adjustURL(source string, duration, timeout time.Duration) (string, time.Duration) {
u, err := url.Parse(source)
if err != nil || (u.Host == "" && u.Scheme != "" && u.Scheme != "file") {
// Try adding http:// to catch sources of the form hostname:port/path.
// url.Parse treats "hostname" as the scheme.
u, e... | [
"func",
"adjustURL",
"(",
"source",
"string",
",",
"duration",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"string",
",",
"time",
".",
"Duration",
")",
"{",
"u",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"source",
")",
"\n",
"if",
"err",
"... | // adjustURL validates if a profile source is a URL and returns an
// cleaned up URL and the timeout to use for retrieval over HTTP.
// If the source cannot be recognized as a URL it returns an empty string. | [
"adjustURL",
"validates",
"if",
"a",
"profile",
"source",
"is",
"a",
"URL",
"and",
"returns",
"an",
"cleaned",
"up",
"URL",
"and",
"the",
"timeout",
"to",
"use",
"for",
"retrieval",
"over",
"HTTP",
".",
"If",
"the",
"source",
"cannot",
"be",
"recognized",
... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/fetch.go#L556-L587 | train |
google/pprof | internal/transport/transport.go | New | func New(flagset plugin.FlagSet) http.RoundTripper {
if flagset == nil {
return &transport{}
}
flagset.AddExtraUsage(extraUsage)
return &transport{
cert: flagset.String("tls_cert", "", "TLS client certificate file for fetching profile and symbols"),
key: flagset.String("tls_key", "", "TLS private key file fo... | go | func New(flagset plugin.FlagSet) http.RoundTripper {
if flagset == nil {
return &transport{}
}
flagset.AddExtraUsage(extraUsage)
return &transport{
cert: flagset.String("tls_cert", "", "TLS client certificate file for fetching profile and symbols"),
key: flagset.String("tls_key", "", "TLS private key file fo... | [
"func",
"New",
"(",
"flagset",
"plugin",
".",
"FlagSet",
")",
"http",
".",
"RoundTripper",
"{",
"if",
"flagset",
"==",
"nil",
"{",
"return",
"&",
"transport",
"{",
"}",
"\n",
"}",
"\n",
"flagset",
".",
"AddExtraUsage",
"(",
"extraUsage",
")",
"\n",
"re... | // New returns a round tripper for making requests with the
// specified cert, key, and ca. The flags tls_cert, tls_key, and tls_ca are
// added to the flagset to allow a user to specify the cert, key, and ca. If
// the flagset is nil, no flags will be added, and users will not be able to
// use these flags. | [
"New",
"returns",
"a",
"round",
"tripper",
"for",
"making",
"requests",
"with",
"the",
"specified",
"cert",
"key",
"and",
"ca",
".",
"The",
"flags",
"tls_cert",
"tls_key",
"and",
"tls_ca",
"are",
"added",
"to",
"the",
"flagset",
"to",
"allow",
"a",
"user",... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/transport/transport.go#L49-L59 | train |
google/pprof | internal/transport/transport.go | initialize | func (tr *transport) initialize() error {
var cert, key, ca string
if tr.cert != nil {
cert = *tr.cert
}
if tr.key != nil {
key = *tr.key
}
if tr.ca != nil {
ca = *tr.ca
}
if cert != "" && key != "" {
tlsCert, err := tls.LoadX509KeyPair(cert, key)
if err != nil {
return fmt.Errorf("could not load ... | go | func (tr *transport) initialize() error {
var cert, key, ca string
if tr.cert != nil {
cert = *tr.cert
}
if tr.key != nil {
key = *tr.key
}
if tr.ca != nil {
ca = *tr.ca
}
if cert != "" && key != "" {
tlsCert, err := tls.LoadX509KeyPair(cert, key)
if err != nil {
return fmt.Errorf("could not load ... | [
"func",
"(",
"tr",
"*",
"transport",
")",
"initialize",
"(",
")",
"error",
"{",
"var",
"cert",
",",
"key",
",",
"ca",
"string",
"\n",
"if",
"tr",
".",
"cert",
"!=",
"nil",
"{",
"cert",
"=",
"*",
"tr",
".",
"cert",
"\n",
"}",
"\n",
"if",
"tr",
... | // initialize uses the cert, key, and ca to initialize the certs
// to use these when making requests. | [
"initialize",
"uses",
"the",
"cert",
"key",
"and",
"ca",
"to",
"initialize",
"the",
"certs",
"to",
"use",
"these",
"when",
"making",
"requests",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/transport/transport.go#L63-L98 | train |
google/pprof | internal/driver/tempfile.go | newTempFile | func newTempFile(dir, prefix, suffix string) (*os.File, error) {
for index := 1; index < 10000; index++ {
path := filepath.Join(dir, fmt.Sprintf("%s%03d%s", prefix, index, suffix))
if _, err := os.Stat(path); err != nil {
return os.Create(path)
}
}
// Give up
return nil, fmt.Errorf("could not create file o... | go | func newTempFile(dir, prefix, suffix string) (*os.File, error) {
for index := 1; index < 10000; index++ {
path := filepath.Join(dir, fmt.Sprintf("%s%03d%s", prefix, index, suffix))
if _, err := os.Stat(path); err != nil {
return os.Create(path)
}
}
// Give up
return nil, fmt.Errorf("could not create file o... | [
"func",
"newTempFile",
"(",
"dir",
",",
"prefix",
",",
"suffix",
"string",
")",
"(",
"*",
"os",
".",
"File",
",",
"error",
")",
"{",
"for",
"index",
":=",
"1",
";",
"index",
"<",
"10000",
";",
"index",
"++",
"{",
"path",
":=",
"filepath",
".",
"J... | // newTempFile returns a new output file in dir with the provided prefix and suffix. | [
"newTempFile",
"returns",
"a",
"new",
"output",
"file",
"in",
"dir",
"with",
"the",
"provided",
"prefix",
"and",
"suffix",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/tempfile.go#L25-L34 | train |
google/pprof | internal/driver/tempfile.go | cleanupTempFiles | func cleanupTempFiles() {
tempFilesMu.Lock()
for _, f := range tempFiles {
os.Remove(f)
}
tempFiles = nil
tempFilesMu.Unlock()
} | go | func cleanupTempFiles() {
tempFilesMu.Lock()
for _, f := range tempFiles {
os.Remove(f)
}
tempFiles = nil
tempFilesMu.Unlock()
} | [
"func",
"cleanupTempFiles",
"(",
")",
"{",
"tempFilesMu",
".",
"Lock",
"(",
")",
"\n",
"for",
"_",
",",
"f",
":=",
"range",
"tempFiles",
"{",
"os",
".",
"Remove",
"(",
"f",
")",
"\n",
"}",
"\n",
"tempFiles",
"=",
"nil",
"\n",
"tempFilesMu",
".",
"U... | // cleanupTempFiles removes any temporary files selected for deferred cleaning. | [
"cleanupTempFiles",
"removes",
"any",
"temporary",
"files",
"selected",
"for",
"deferred",
"cleaning",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/tempfile.go#L47-L54 | train |
google/pprof | internal/report/source.go | getSourceFromFile | func getSourceFromFile(file string, reader *sourceReader, fns graph.Nodes, start, end int) (graph.Nodes, string, error) {
lineNodes := make(map[int]graph.Nodes)
// Collect source coordinates from profile.
const margin = 5 // Lines before first/after last sample.
if start == 0 {
if fns[0].Info.StartLine != 0 {
... | go | func getSourceFromFile(file string, reader *sourceReader, fns graph.Nodes, start, end int) (graph.Nodes, string, error) {
lineNodes := make(map[int]graph.Nodes)
// Collect source coordinates from profile.
const margin = 5 // Lines before first/after last sample.
if start == 0 {
if fns[0].Info.StartLine != 0 {
... | [
"func",
"getSourceFromFile",
"(",
"file",
"string",
",",
"reader",
"*",
"sourceReader",
",",
"fns",
"graph",
".",
"Nodes",
",",
"start",
",",
"end",
"int",
")",
"(",
"graph",
".",
"Nodes",
",",
"string",
",",
"error",
")",
"{",
"lineNodes",
":=",
"make... | // getSourceFromFile collects the sources of a function from a source
// file and annotates it with the samples in fns. Returns the sources
// as nodes, using the info.name field to hold the source code. | [
"getSourceFromFile",
"collects",
"the",
"sources",
"of",
"a",
"function",
"from",
"a",
"source",
"file",
"and",
"annotates",
"it",
"with",
"the",
"samples",
"in",
"fns",
".",
"Returns",
"the",
"sources",
"as",
"nodes",
"using",
"the",
"info",
".",
"name",
... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/report/source.go#L427-L483 | train |
google/pprof | internal/report/source.go | openSourceFile | func openSourceFile(path, searchPath, trim string) (*os.File, error) {
path = trimPath(path, trim, searchPath)
// If file is still absolute, require file to exist.
if filepath.IsAbs(path) {
f, err := os.Open(path)
return f, err
}
// Scan each component of the path.
for _, dir := range filepath.SplitList(searc... | go | func openSourceFile(path, searchPath, trim string) (*os.File, error) {
path = trimPath(path, trim, searchPath)
// If file is still absolute, require file to exist.
if filepath.IsAbs(path) {
f, err := os.Open(path)
return f, err
}
// Scan each component of the path.
for _, dir := range filepath.SplitList(searc... | [
"func",
"openSourceFile",
"(",
"path",
",",
"searchPath",
",",
"trim",
"string",
")",
"(",
"*",
"os",
".",
"File",
",",
"error",
")",
"{",
"path",
"=",
"trimPath",
"(",
"path",
",",
"trim",
",",
"searchPath",
")",
"\n",
"// If file is still absolute, requi... | // openSourceFile opens a source file from a name encoded in a profile. File
// names in a profile after can be relative paths, so search them in each of
// the paths in searchPath and their parents. In case the profile contains
// absolute paths, additional paths may be configured to trim from the source
// paths in t... | [
"openSourceFile",
"opens",
"a",
"source",
"file",
"from",
"a",
"name",
"encoded",
"in",
"a",
"profile",
".",
"File",
"names",
"in",
"a",
"profile",
"after",
"can",
"be",
"relative",
"paths",
"so",
"search",
"them",
"in",
"each",
"of",
"the",
"paths",
"in... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/report/source.go#L578-L602 | train |
google/pprof | internal/report/source_html.go | AddSourceTemplates | func AddSourceTemplates(t *template.Template) {
template.Must(t.Parse(`{{define "weblistcss"}}` + weblistPageCSS + `{{end}}`))
template.Must(t.Parse(`{{define "weblistjs"}}` + weblistPageScript + `{{end}}`))
} | go | func AddSourceTemplates(t *template.Template) {
template.Must(t.Parse(`{{define "weblistcss"}}` + weblistPageCSS + `{{end}}`))
template.Must(t.Parse(`{{define "weblistjs"}}` + weblistPageScript + `{{end}}`))
} | [
"func",
"AddSourceTemplates",
"(",
"t",
"*",
"template",
".",
"Template",
")",
"{",
"template",
".",
"Must",
"(",
"t",
".",
"Parse",
"(",
"`{{define \"weblistcss\"}}`",
"+",
"weblistPageCSS",
"+",
"`{{end}}`",
")",
")",
"\n",
"template",
".",
"Must",
"(",
... | // AddSourceTemplates adds templates used by PrintWebList to t. | [
"AddSourceTemplates",
"adds",
"templates",
"used",
"by",
"PrintWebList",
"to",
"t",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/report/source_html.go#L22-L25 | train |
google/pprof | profile/encode.go | padStringArray | func padStringArray(arr []string, l int) []string {
if l <= len(arr) {
return arr
}
return append(arr, make([]string, l-len(arr))...)
} | go | func padStringArray(arr []string, l int) []string {
if l <= len(arr) {
return arr
}
return append(arr, make([]string, l-len(arr))...)
} | [
"func",
"padStringArray",
"(",
"arr",
"[",
"]",
"string",
",",
"l",
"int",
")",
"[",
"]",
"string",
"{",
"if",
"l",
"<=",
"len",
"(",
"arr",
")",
"{",
"return",
"arr",
"\n",
"}",
"\n",
"return",
"append",
"(",
"arr",
",",
"make",
"(",
"[",
"]",... | // padStringArray pads arr with enough empty strings to make arr
// length l when arr's length is less than l. | [
"padStringArray",
"pads",
"arr",
"with",
"enough",
"empty",
"strings",
"to",
"make",
"arr",
"length",
"l",
"when",
"arr",
"s",
"length",
"is",
"less",
"than",
"l",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/encode.go#L372-L377 | train |
google/pprof | internal/binutils/addr2liner.go | newAddr2Liner | func newAddr2Liner(cmd, file string, base uint64) (*addr2Liner, error) {
if cmd == "" {
cmd = defaultAddr2line
}
j := &addr2LinerJob{
cmd: exec.Command(cmd, "-aif", "-e", file),
}
var err error
if j.in, err = j.cmd.StdinPipe(); err != nil {
return nil, err
}
outPipe, err := j.cmd.StdoutPipe()
if err !... | go | func newAddr2Liner(cmd, file string, base uint64) (*addr2Liner, error) {
if cmd == "" {
cmd = defaultAddr2line
}
j := &addr2LinerJob{
cmd: exec.Command(cmd, "-aif", "-e", file),
}
var err error
if j.in, err = j.cmd.StdinPipe(); err != nil {
return nil, err
}
outPipe, err := j.cmd.StdoutPipe()
if err !... | [
"func",
"newAddr2Liner",
"(",
"cmd",
",",
"file",
"string",
",",
"base",
"uint64",
")",
"(",
"*",
"addr2Liner",
",",
"error",
")",
"{",
"if",
"cmd",
"==",
"\"",
"\"",
"{",
"cmd",
"=",
"defaultAddr2line",
"\n",
"}",
"\n\n",
"j",
":=",
"&",
"addr2Liner... | // newAddr2liner starts the given addr2liner command reporting
// information about the given executable file. If file is a shared
// library, base should be the address at which it was mapped in the
// program under consideration. | [
"newAddr2liner",
"starts",
"the",
"given",
"addr2liner",
"command",
"reporting",
"information",
"about",
"the",
"given",
"executable",
"file",
".",
"If",
"file",
"is",
"a",
"shared",
"library",
"base",
"should",
"be",
"the",
"address",
"at",
"which",
"it",
"wa... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/binutils/addr2liner.go#L86-L116 | train |
google/pprof | internal/binutils/addr2liner.go | readFrame | func (d *addr2Liner) readFrame() (plugin.Frame, bool) {
funcname, err := d.readString()
if err != nil {
return plugin.Frame{}, true
}
if strings.HasPrefix(funcname, "0x") {
// If addr2line returns a hex address we can assume it is the
// sentinel. Read and ignore next two lines of output from
// addr2line
... | go | func (d *addr2Liner) readFrame() (plugin.Frame, bool) {
funcname, err := d.readString()
if err != nil {
return plugin.Frame{}, true
}
if strings.HasPrefix(funcname, "0x") {
// If addr2line returns a hex address we can assume it is the
// sentinel. Read and ignore next two lines of output from
// addr2line
... | [
"func",
"(",
"d",
"*",
"addr2Liner",
")",
"readFrame",
"(",
")",
"(",
"plugin",
".",
"Frame",
",",
"bool",
")",
"{",
"funcname",
",",
"err",
":=",
"d",
".",
"readString",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"plugin",
".",
"Fr... | // readFrame parses the addr2line output for a single address. It
// returns a populated plugin.Frame and whether it has reached the end of the
// data. | [
"readFrame",
"parses",
"the",
"addr2line",
"output",
"for",
"a",
"single",
"address",
".",
"It",
"returns",
"a",
"populated",
"plugin",
".",
"Frame",
"and",
"whether",
"it",
"has",
"reached",
"the",
"end",
"of",
"the",
"data",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/binutils/addr2liner.go#L129-L175 | train |
google/pprof | internal/driver/driver.go | identifyNumLabelUnits | func identifyNumLabelUnits(p *profile.Profile, ui plugin.UI) map[string]string {
numLabelUnits, ignoredUnits := p.NumLabelUnits()
// Print errors for tags with multiple units associated with
// a single key.
for k, units := range ignoredUnits {
ui.PrintErr(fmt.Sprintf("For tag %s used unit %s, also encountered u... | go | func identifyNumLabelUnits(p *profile.Profile, ui plugin.UI) map[string]string {
numLabelUnits, ignoredUnits := p.NumLabelUnits()
// Print errors for tags with multiple units associated with
// a single key.
for k, units := range ignoredUnits {
ui.PrintErr(fmt.Sprintf("For tag %s used unit %s, also encountered u... | [
"func",
"identifyNumLabelUnits",
"(",
"p",
"*",
"profile",
".",
"Profile",
",",
"ui",
"plugin",
".",
"UI",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"numLabelUnits",
",",
"ignoredUnits",
":=",
"p",
".",
"NumLabelUnits",
"(",
")",
"\n\n",
"// Print err... | // identifyNumLabelUnits returns a map of numeric label keys to the units
// associated with those keys. | [
"identifyNumLabelUnits",
"returns",
"a",
"map",
"of",
"numeric",
"label",
"keys",
"to",
"the",
"units",
"associated",
"with",
"those",
"keys",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/driver.go#L295-L304 | train |
google/pprof | internal/binutils/disasm.go | disassemble | func disassemble(asm []byte) ([]plugin.Inst, error) {
buf := bytes.NewBuffer(asm)
function, file, line := "", "", 0
var assembly []plugin.Inst
for {
input, err := buf.ReadString('\n')
if err != nil {
if err != io.EOF {
return nil, err
}
if input == "" {
break
}
}
if fields := objdumpAsm... | go | func disassemble(asm []byte) ([]plugin.Inst, error) {
buf := bytes.NewBuffer(asm)
function, file, line := "", "", 0
var assembly []plugin.Inst
for {
input, err := buf.ReadString('\n')
if err != nil {
if err != io.EOF {
return nil, err
}
if input == "" {
break
}
}
if fields := objdumpAsm... | [
"func",
"disassemble",
"(",
"asm",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"plugin",
".",
"Inst",
",",
"error",
")",
"{",
"buf",
":=",
"bytes",
".",
"NewBuffer",
"(",
"asm",
")",
"\n",
"function",
",",
"file",
",",
"line",
":=",
"\"",
"\"",
",",
... | // disassemble parses the output of the objdump command and returns
// the assembly instructions in a slice. | [
"disassemble",
"parses",
"the",
"output",
"of",
"the",
"objdump",
"command",
"and",
"returns",
"the",
"assembly",
"instructions",
"in",
"a",
"slice",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/binutils/disasm.go#L109-L152 | train |
google/pprof | internal/binutils/disasm.go | nextSymbol | func nextSymbol(buf *bytes.Buffer) (uint64, string, error) {
for {
line, err := buf.ReadString('\n')
if err != nil {
if err != io.EOF || line == "" {
return 0, "", err
}
}
if fields := nmOutputRE.FindStringSubmatch(line); len(fields) == 4 {
if address, err := strconv.ParseUint(fields[1], 16, 64);... | go | func nextSymbol(buf *bytes.Buffer) (uint64, string, error) {
for {
line, err := buf.ReadString('\n')
if err != nil {
if err != io.EOF || line == "" {
return 0, "", err
}
}
if fields := nmOutputRE.FindStringSubmatch(line); len(fields) == 4 {
if address, err := strconv.ParseUint(fields[1], 16, 64);... | [
"func",
"nextSymbol",
"(",
"buf",
"*",
"bytes",
".",
"Buffer",
")",
"(",
"uint64",
",",
"string",
",",
"error",
")",
"{",
"for",
"{",
"line",
",",
"err",
":=",
"buf",
".",
"ReadString",
"(",
"'\\n'",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if"... | // nextSymbol parses the nm output to find the next symbol listed.
// Skips over any output it cannot recognize. | [
"nextSymbol",
"parses",
"the",
"nm",
"output",
"to",
"find",
"the",
"next",
"symbol",
"listed",
".",
"Skips",
"over",
"any",
"output",
"it",
"cannot",
"recognize",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/binutils/disasm.go#L156-L171 | train |
google/pprof | profile/filter.go | FilterSamplesByName | func (p *Profile) FilterSamplesByName(focus, ignore, hide, show *regexp.Regexp) (fm, im, hm, hnm bool) {
focusOrIgnore := make(map[uint64]bool)
hidden := make(map[uint64]bool)
for _, l := range p.Location {
if ignore != nil && l.matchesName(ignore) {
im = true
focusOrIgnore[l.ID] = false
} else if focus ==... | go | func (p *Profile) FilterSamplesByName(focus, ignore, hide, show *regexp.Regexp) (fm, im, hm, hnm bool) {
focusOrIgnore := make(map[uint64]bool)
hidden := make(map[uint64]bool)
for _, l := range p.Location {
if ignore != nil && l.matchesName(ignore) {
im = true
focusOrIgnore[l.ID] = false
} else if focus ==... | [
"func",
"(",
"p",
"*",
"Profile",
")",
"FilterSamplesByName",
"(",
"focus",
",",
"ignore",
",",
"hide",
",",
"show",
"*",
"regexp",
".",
"Regexp",
")",
"(",
"fm",
",",
"im",
",",
"hm",
",",
"hnm",
"bool",
")",
"{",
"focusOrIgnore",
":=",
"make",
"(... | // FilterSamplesByName filters the samples in a profile and only keeps
// samples where at least one frame matches focus but none match ignore.
// Returns true is the corresponding regexp matched at least one sample. | [
"FilterSamplesByName",
"filters",
"the",
"samples",
"in",
"a",
"profile",
"and",
"only",
"keeps",
"samples",
"where",
"at",
"least",
"one",
"frame",
"matches",
"focus",
"but",
"none",
"match",
"ignore",
".",
"Returns",
"true",
"is",
"the",
"corresponding",
"re... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/filter.go#L24-L75 | train |
google/pprof | profile/filter.go | filterShowFromLocation | func filterShowFromLocation(loc *Location, showFrom *regexp.Regexp) bool {
if m := loc.Mapping; m != nil && showFrom.MatchString(m.File) {
return true
}
if i := loc.lastMatchedLineIndex(showFrom); i >= 0 {
loc.Line = loc.Line[:i+1]
return true
}
return false
} | go | func filterShowFromLocation(loc *Location, showFrom *regexp.Regexp) bool {
if m := loc.Mapping; m != nil && showFrom.MatchString(m.File) {
return true
}
if i := loc.lastMatchedLineIndex(showFrom); i >= 0 {
loc.Line = loc.Line[:i+1]
return true
}
return false
} | [
"func",
"filterShowFromLocation",
"(",
"loc",
"*",
"Location",
",",
"showFrom",
"*",
"regexp",
".",
"Regexp",
")",
"bool",
"{",
"if",
"m",
":=",
"loc",
".",
"Mapping",
";",
"m",
"!=",
"nil",
"&&",
"showFrom",
".",
"MatchString",
"(",
"m",
".",
"File",
... | // filterShowFromLocation tests a showFrom regex against a location, removes
// lines after the last match and returns whether a match was found. If the
// mapping is matched, then all lines are kept. | [
"filterShowFromLocation",
"tests",
"a",
"showFrom",
"regex",
"against",
"a",
"location",
"removes",
"lines",
"after",
"the",
"last",
"match",
"and",
"returns",
"whether",
"a",
"match",
"was",
"found",
".",
"If",
"the",
"mapping",
"is",
"matched",
"then",
"all"... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/filter.go#L118-L127 | train |
google/pprof | profile/filter.go | lastMatchedLineIndex | func (loc *Location) lastMatchedLineIndex(re *regexp.Regexp) int {
for i := len(loc.Line) - 1; i >= 0; i-- {
if fn := loc.Line[i].Function; fn != nil {
if re.MatchString(fn.Name) || re.MatchString(fn.Filename) {
return i
}
}
}
return -1
} | go | func (loc *Location) lastMatchedLineIndex(re *regexp.Regexp) int {
for i := len(loc.Line) - 1; i >= 0; i-- {
if fn := loc.Line[i].Function; fn != nil {
if re.MatchString(fn.Name) || re.MatchString(fn.Filename) {
return i
}
}
}
return -1
} | [
"func",
"(",
"loc",
"*",
"Location",
")",
"lastMatchedLineIndex",
"(",
"re",
"*",
"regexp",
".",
"Regexp",
")",
"int",
"{",
"for",
"i",
":=",
"len",
"(",
"loc",
".",
"Line",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
"{",
"if",
"fn",
... | // lastMatchedLineIndex returns the index of the last line that matches a regex,
// or -1 if no match is found. | [
"lastMatchedLineIndex",
"returns",
"the",
"index",
"of",
"the",
"last",
"line",
"that",
"matches",
"a",
"regex",
"or",
"-",
"1",
"if",
"no",
"match",
"is",
"found",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/filter.go#L131-L140 | train |
google/pprof | profile/filter.go | FilterTagsByName | func (p *Profile) FilterTagsByName(show, hide *regexp.Regexp) (sm, hm bool) {
matchRemove := func(name string) bool {
matchShow := show == nil || show.MatchString(name)
matchHide := hide != nil && hide.MatchString(name)
if matchShow {
sm = true
}
if matchHide {
hm = true
}
return !matchShow || mat... | go | func (p *Profile) FilterTagsByName(show, hide *regexp.Regexp) (sm, hm bool) {
matchRemove := func(name string) bool {
matchShow := show == nil || show.MatchString(name)
matchHide := hide != nil && hide.MatchString(name)
if matchShow {
sm = true
}
if matchHide {
hm = true
}
return !matchShow || mat... | [
"func",
"(",
"p",
"*",
"Profile",
")",
"FilterTagsByName",
"(",
"show",
",",
"hide",
"*",
"regexp",
".",
"Regexp",
")",
"(",
"sm",
",",
"hm",
"bool",
")",
"{",
"matchRemove",
":=",
"func",
"(",
"name",
"string",
")",
"bool",
"{",
"matchShow",
":=",
... | // FilterTagsByName filters the tags in a profile and only keeps
// tags that match show and not hide. | [
"FilterTagsByName",
"filters",
"the",
"tags",
"in",
"a",
"profile",
"and",
"only",
"keeps",
"tags",
"that",
"match",
"show",
"and",
"not",
"hide",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/filter.go#L144-L170 | train |
google/pprof | profile/filter.go | FilterSamplesByTag | func (p *Profile) FilterSamplesByTag(focus, ignore TagMatch) (fm, im bool) {
samples := make([]*Sample, 0, len(p.Sample))
for _, s := range p.Sample {
focused, ignored := true, false
if focus != nil {
focused = focus(s)
}
if ignore != nil {
ignored = ignore(s)
}
fm = fm || focused
im = im || ignor... | go | func (p *Profile) FilterSamplesByTag(focus, ignore TagMatch) (fm, im bool) {
samples := make([]*Sample, 0, len(p.Sample))
for _, s := range p.Sample {
focused, ignored := true, false
if focus != nil {
focused = focus(s)
}
if ignore != nil {
ignored = ignore(s)
}
fm = fm || focused
im = im || ignor... | [
"func",
"(",
"p",
"*",
"Profile",
")",
"FilterSamplesByTag",
"(",
"focus",
",",
"ignore",
"TagMatch",
")",
"(",
"fm",
",",
"im",
"bool",
")",
"{",
"samples",
":=",
"make",
"(",
"[",
"]",
"*",
"Sample",
",",
"0",
",",
"len",
"(",
"p",
".",
"Sample... | // FilterSamplesByTag removes all samples from the profile, except
// those that match focus and do not match the ignore regular
// expression. | [
"FilterSamplesByTag",
"removes",
"all",
"samples",
"from",
"the",
"profile",
"except",
"those",
"that",
"match",
"focus",
"and",
"do",
"not",
"match",
"the",
"ignore",
"regular",
"expression",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/filter.go#L252-L270 | train |
google/pprof | profile/profile.go | ParseData | func ParseData(data []byte) (*Profile, error) {
var p *Profile
var err error
if len(data) >= 2 && data[0] == 0x1f && data[1] == 0x8b {
gz, err := gzip.NewReader(bytes.NewBuffer(data))
if err == nil {
data, err = ioutil.ReadAll(gz)
}
if err != nil {
return nil, fmt.Errorf("decompressing profile: %v", er... | go | func ParseData(data []byte) (*Profile, error) {
var p *Profile
var err error
if len(data) >= 2 && data[0] == 0x1f && data[1] == 0x8b {
gz, err := gzip.NewReader(bytes.NewBuffer(data))
if err == nil {
data, err = ioutil.ReadAll(gz)
}
if err != nil {
return nil, fmt.Errorf("decompressing profile: %v", er... | [
"func",
"ParseData",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"*",
"Profile",
",",
"error",
")",
"{",
"var",
"p",
"*",
"Profile",
"\n",
"var",
"err",
"error",
"\n",
"if",
"len",
"(",
"data",
")",
">=",
"2",
"&&",
"data",
"[",
"0",
"]",
"==",
... | // ParseData parses a profile from a buffer and checks for its
// validity. | [
"ParseData",
"parses",
"a",
"profile",
"from",
"a",
"buffer",
"and",
"checks",
"for",
"its",
"validity",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L155-L179 | train |
google/pprof | profile/profile.go | ParseUncompressed | func ParseUncompressed(data []byte) (*Profile, error) {
if len(data) == 0 {
return nil, errNoData
}
p := &Profile{}
if err := unmarshal(data, p); err != nil {
return nil, err
}
if err := p.postDecode(); err != nil {
return nil, err
}
return p, nil
} | go | func ParseUncompressed(data []byte) (*Profile, error) {
if len(data) == 0 {
return nil, errNoData
}
p := &Profile{}
if err := unmarshal(data, p); err != nil {
return nil, err
}
if err := p.postDecode(); err != nil {
return nil, err
}
return p, nil
} | [
"func",
"ParseUncompressed",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"*",
"Profile",
",",
"error",
")",
"{",
"if",
"len",
"(",
"data",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"errNoData",
"\n",
"}",
"\n",
"p",
":=",
"&",
"Profile",
"{",
"}",
... | // ParseUncompressed parses an uncompressed protobuf into a profile. | [
"ParseUncompressed",
"parses",
"an",
"uncompressed",
"protobuf",
"into",
"a",
"profile",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L210-L224 | train |
google/pprof | profile/profile.go | massageMappings | func (p *Profile) massageMappings() {
// Merge adjacent regions with matching names, checking that the offsets match
if len(p.Mapping) > 1 {
mappings := []*Mapping{p.Mapping[0]}
for _, m := range p.Mapping[1:] {
lm := mappings[len(mappings)-1]
if adjacent(lm, m) {
lm.Limit = m.Limit
if m.File != "" ... | go | func (p *Profile) massageMappings() {
// Merge adjacent regions with matching names, checking that the offsets match
if len(p.Mapping) > 1 {
mappings := []*Mapping{p.Mapping[0]}
for _, m := range p.Mapping[1:] {
lm := mappings[len(mappings)-1]
if adjacent(lm, m) {
lm.Limit = m.Limit
if m.File != "" ... | [
"func",
"(",
"p",
"*",
"Profile",
")",
"massageMappings",
"(",
")",
"{",
"// Merge adjacent regions with matching names, checking that the offsets match",
"if",
"len",
"(",
"p",
".",
"Mapping",
")",
">",
"1",
"{",
"mappings",
":=",
"[",
"]",
"*",
"Mapping",
"{",... | // massageMappings applies heuristic-based changes to the profile
// mappings to account for quirks of some environments. | [
"massageMappings",
"applies",
"heuristic",
"-",
"based",
"changes",
"to",
"the",
"profile",
"mappings",
"to",
"account",
"for",
"quirks",
"of",
"some",
"environments",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L230-L273 | train |
google/pprof | profile/profile.go | adjacent | func adjacent(m1, m2 *Mapping) bool {
if m1.File != "" && m2.File != "" {
if m1.File != m2.File {
return false
}
}
if m1.BuildID != "" && m2.BuildID != "" {
if m1.BuildID != m2.BuildID {
return false
}
}
if m1.Limit != m2.Start {
return false
}
if m1.Offset != 0 && m2.Offset != 0 {
offset := m1... | go | func adjacent(m1, m2 *Mapping) bool {
if m1.File != "" && m2.File != "" {
if m1.File != m2.File {
return false
}
}
if m1.BuildID != "" && m2.BuildID != "" {
if m1.BuildID != m2.BuildID {
return false
}
}
if m1.Limit != m2.Start {
return false
}
if m1.Offset != 0 && m2.Offset != 0 {
offset := m1... | [
"func",
"adjacent",
"(",
"m1",
",",
"m2",
"*",
"Mapping",
")",
"bool",
"{",
"if",
"m1",
".",
"File",
"!=",
"\"",
"\"",
"&&",
"m2",
".",
"File",
"!=",
"\"",
"\"",
"{",
"if",
"m1",
".",
"File",
"!=",
"m2",
".",
"File",
"{",
"return",
"false",
"... | // adjacent returns whether two mapping entries represent the same
// mapping that has been split into two. Check that their addresses are adjacent,
// and if the offsets match, if they are available. | [
"adjacent",
"returns",
"whether",
"two",
"mapping",
"entries",
"represent",
"the",
"same",
"mapping",
"that",
"has",
"been",
"split",
"into",
"two",
".",
"Check",
"that",
"their",
"addresses",
"are",
"adjacent",
"and",
"if",
"the",
"offsets",
"match",
"if",
... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L278-L299 | train |
google/pprof | profile/profile.go | WriteUncompressed | func (p *Profile) WriteUncompressed(w io.Writer) error {
_, err := w.Write(serialize(p))
return err
} | go | func (p *Profile) WriteUncompressed(w io.Writer) error {
_, err := w.Write(serialize(p))
return err
} | [
"func",
"(",
"p",
"*",
"Profile",
")",
"WriteUncompressed",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"_",
",",
"err",
":=",
"w",
".",
"Write",
"(",
"serialize",
"(",
"p",
")",
")",
"\n",
"return",
"err",
"\n",
"}"
] | // WriteUncompressed writes the profile as a marshaled protobuf. | [
"WriteUncompressed",
"writes",
"the",
"profile",
"as",
"a",
"marshaled",
"protobuf",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L326-L329 | train |
google/pprof | profile/profile.go | Aggregate | func (p *Profile) Aggregate(inlineFrame, function, filename, linenumber, address bool) error {
for _, m := range p.Mapping {
m.HasInlineFrames = m.HasInlineFrames && inlineFrame
m.HasFunctions = m.HasFunctions && function
m.HasFilenames = m.HasFilenames && filename
m.HasLineNumbers = m.HasLineNumbers && linenu... | go | func (p *Profile) Aggregate(inlineFrame, function, filename, linenumber, address bool) error {
for _, m := range p.Mapping {
m.HasInlineFrames = m.HasInlineFrames && inlineFrame
m.HasFunctions = m.HasFunctions && function
m.HasFilenames = m.HasFilenames && filename
m.HasLineNumbers = m.HasLineNumbers && linenu... | [
"func",
"(",
"p",
"*",
"Profile",
")",
"Aggregate",
"(",
"inlineFrame",
",",
"function",
",",
"filename",
",",
"linenumber",
",",
"address",
"bool",
")",
"error",
"{",
"for",
"_",
",",
"m",
":=",
"range",
"p",
".",
"Mapping",
"{",
"m",
".",
"HasInlin... | // Aggregate merges the locations in the profile into equivalence
// classes preserving the request attributes. It also updates the
// samples to point to the merged locations. | [
"Aggregate",
"merges",
"the",
"locations",
"in",
"the",
"profile",
"into",
"equivalence",
"classes",
"preserving",
"the",
"request",
"attributes",
".",
"It",
"also",
"updates",
"the",
"samples",
"to",
"point",
"to",
"the",
"merged",
"locations",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L414-L453 | train |
google/pprof | profile/profile.go | NumLabelUnits | func (p *Profile) NumLabelUnits() (map[string]string, map[string][]string) {
numLabelUnits := map[string]string{}
ignoredUnits := map[string]map[string]bool{}
encounteredKeys := map[string]bool{}
// Determine units based on numeric tags for each sample.
for _, s := range p.Sample {
for k := range s.NumLabel {
... | go | func (p *Profile) NumLabelUnits() (map[string]string, map[string][]string) {
numLabelUnits := map[string]string{}
ignoredUnits := map[string]map[string]bool{}
encounteredKeys := map[string]bool{}
// Determine units based on numeric tags for each sample.
for _, s := range p.Sample {
for k := range s.NumLabel {
... | [
"func",
"(",
"p",
"*",
"Profile",
")",
"NumLabelUnits",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"{",
"numLabelUnits",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
... | // NumLabelUnits returns a map of numeric label keys to the units
// associated with those keys and a map of those keys to any units
// that were encountered but not used.
// Unit for a given key is the first encountered unit for that key. If multiple
// units are encountered for values paired with a particular key, th... | [
"NumLabelUnits",
"returns",
"a",
"map",
"of",
"numeric",
"label",
"keys",
"to",
"the",
"units",
"associated",
"with",
"those",
"keys",
"and",
"a",
"map",
"of",
"those",
"keys",
"to",
"any",
"units",
"that",
"were",
"encountered",
"but",
"not",
"used",
".",... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L464-L517 | train |
google/pprof | profile/profile.go | String | func (p *Profile) String() string {
ss := make([]string, 0, len(p.Comments)+len(p.Sample)+len(p.Mapping)+len(p.Location))
for _, c := range p.Comments {
ss = append(ss, "Comment: "+c)
}
if pt := p.PeriodType; pt != nil {
ss = append(ss, fmt.Sprintf("PeriodType: %s %s", pt.Type, pt.Unit))
}
ss = append(ss, fmt... | go | func (p *Profile) String() string {
ss := make([]string, 0, len(p.Comments)+len(p.Sample)+len(p.Mapping)+len(p.Location))
for _, c := range p.Comments {
ss = append(ss, "Comment: "+c)
}
if pt := p.PeriodType; pt != nil {
ss = append(ss, fmt.Sprintf("PeriodType: %s %s", pt.Type, pt.Unit))
}
ss = append(ss, fmt... | [
"func",
"(",
"p",
"*",
"Profile",
")",
"String",
"(",
")",
"string",
"{",
"ss",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"0",
",",
"len",
"(",
"p",
".",
"Comments",
")",
"+",
"len",
"(",
"p",
".",
"Sample",
")",
"+",
"len",
"(",
"p",
"."... | // String dumps a text representation of a profile. Intended mainly
// for debugging purposes. | [
"String",
"dumps",
"a",
"text",
"representation",
"of",
"a",
"profile",
".",
"Intended",
"mainly",
"for",
"debugging",
"purposes",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L521-L562 | train |
google/pprof | profile/profile.go | string | func (m *Mapping) string() string {
bits := ""
if m.HasFunctions {
bits = bits + "[FN]"
}
if m.HasFilenames {
bits = bits + "[FL]"
}
if m.HasLineNumbers {
bits = bits + "[LN]"
}
if m.HasInlineFrames {
bits = bits + "[IN]"
}
return fmt.Sprintf("%d: %#x/%#x/%#x %s %s %s",
m.ID,
m.Start, m.Limit, m.O... | go | func (m *Mapping) string() string {
bits := ""
if m.HasFunctions {
bits = bits + "[FN]"
}
if m.HasFilenames {
bits = bits + "[FL]"
}
if m.HasLineNumbers {
bits = bits + "[LN]"
}
if m.HasInlineFrames {
bits = bits + "[IN]"
}
return fmt.Sprintf("%d: %#x/%#x/%#x %s %s %s",
m.ID,
m.Start, m.Limit, m.O... | [
"func",
"(",
"m",
"*",
"Mapping",
")",
"string",
"(",
")",
"string",
"{",
"bits",
":=",
"\"",
"\"",
"\n",
"if",
"m",
".",
"HasFunctions",
"{",
"bits",
"=",
"bits",
"+",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"m",
".",
"HasFilenames",
"{",
"bits",
"... | // string dumps a text representation of a mapping. Intended mainly
// for debugging purposes. | [
"string",
"dumps",
"a",
"text",
"representation",
"of",
"a",
"mapping",
".",
"Intended",
"mainly",
"for",
"debugging",
"purposes",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L566-L586 | train |
google/pprof | profile/profile.go | string | func (l *Location) string() string {
ss := []string{}
locStr := fmt.Sprintf("%6d: %#x ", l.ID, l.Address)
if m := l.Mapping; m != nil {
locStr = locStr + fmt.Sprintf("M=%d ", m.ID)
}
if l.IsFolded {
locStr = locStr + "[F] "
}
if len(l.Line) == 0 {
ss = append(ss, locStr)
}
for li := range l.Line {
lnSt... | go | func (l *Location) string() string {
ss := []string{}
locStr := fmt.Sprintf("%6d: %#x ", l.ID, l.Address)
if m := l.Mapping; m != nil {
locStr = locStr + fmt.Sprintf("M=%d ", m.ID)
}
if l.IsFolded {
locStr = locStr + "[F] "
}
if len(l.Line) == 0 {
ss = append(ss, locStr)
}
for li := range l.Line {
lnSt... | [
"func",
"(",
"l",
"*",
"Location",
")",
"string",
"(",
")",
"string",
"{",
"ss",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"locStr",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"l",
".",
"ID",
",",
"l",
".",
"Address",
")",
"\n",
"if",... | // string dumps a text representation of a location. Intended mainly
// for debugging purposes. | [
"string",
"dumps",
"a",
"text",
"representation",
"of",
"a",
"location",
".",
"Intended",
"mainly",
"for",
"debugging",
"purposes",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L590-L619 | train |
google/pprof | profile/profile.go | string | func (s *Sample) string() string {
ss := []string{}
var sv string
for _, v := range s.Value {
sv = fmt.Sprintf("%s %10d", sv, v)
}
sv = sv + ": "
for _, l := range s.Location {
sv = sv + fmt.Sprintf("%d ", l.ID)
}
ss = append(ss, sv)
const labelHeader = " "
if len(s.Label) > 0 {
ss = appe... | go | func (s *Sample) string() string {
ss := []string{}
var sv string
for _, v := range s.Value {
sv = fmt.Sprintf("%s %10d", sv, v)
}
sv = sv + ": "
for _, l := range s.Location {
sv = sv + fmt.Sprintf("%d ", l.ID)
}
ss = append(ss, sv)
const labelHeader = " "
if len(s.Label) > 0 {
ss = appe... | [
"func",
"(",
"s",
"*",
"Sample",
")",
"string",
"(",
")",
"string",
"{",
"ss",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"var",
"sv",
"string",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"s",
".",
"Value",
"{",
"sv",
"=",
"fmt",
".",
"Sprintf... | // string dumps a text representation of a sample. Intended mainly
// for debugging purposes. | [
"string",
"dumps",
"a",
"text",
"representation",
"of",
"a",
"sample",
".",
"Intended",
"mainly",
"for",
"debugging",
"purposes",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L623-L642 | train |
google/pprof | profile/profile.go | labelsToString | func labelsToString(labels map[string][]string) string {
ls := []string{}
for k, v := range labels {
ls = append(ls, fmt.Sprintf("%s:%v", k, v))
}
sort.Strings(ls)
return strings.Join(ls, " ")
} | go | func labelsToString(labels map[string][]string) string {
ls := []string{}
for k, v := range labels {
ls = append(ls, fmt.Sprintf("%s:%v", k, v))
}
sort.Strings(ls)
return strings.Join(ls, " ")
} | [
"func",
"labelsToString",
"(",
"labels",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"string",
"{",
"ls",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"labels",
"{",
"ls",
"=",
"append",
"(",
"ls",
",",
... | // labelsToString returns a string representation of a
// map representing labels. | [
"labelsToString",
"returns",
"a",
"string",
"representation",
"of",
"a",
"map",
"representing",
"labels",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L646-L653 | train |
google/pprof | profile/profile.go | numLabelsToString | func numLabelsToString(numLabels map[string][]int64, numUnits map[string][]string) string {
ls := []string{}
for k, v := range numLabels {
units := numUnits[k]
var labelString string
if len(units) == len(v) {
values := make([]string, len(v))
for i, vv := range v {
values[i] = fmt.Sprintf("%d %s", vv, ... | go | func numLabelsToString(numLabels map[string][]int64, numUnits map[string][]string) string {
ls := []string{}
for k, v := range numLabels {
units := numUnits[k]
var labelString string
if len(units) == len(v) {
values := make([]string, len(v))
for i, vv := range v {
values[i] = fmt.Sprintf("%d %s", vv, ... | [
"func",
"numLabelsToString",
"(",
"numLabels",
"map",
"[",
"string",
"]",
"[",
"]",
"int64",
",",
"numUnits",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"string",
"{",
"ls",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"for",
"k",
",",
"v",
... | // numLabelsToString returns a string representation of a map
// representing numeric labels. | [
"numLabelsToString",
"returns",
"a",
"string",
"representation",
"of",
"a",
"map",
"representing",
"numeric",
"labels",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L657-L675 | train |
google/pprof | profile/profile.go | SetLabel | func (p *Profile) SetLabel(key string, value []string) {
for _, sample := range p.Sample {
if sample.Label == nil {
sample.Label = map[string][]string{key: value}
} else {
sample.Label[key] = value
}
}
} | go | func (p *Profile) SetLabel(key string, value []string) {
for _, sample := range p.Sample {
if sample.Label == nil {
sample.Label = map[string][]string{key: value}
} else {
sample.Label[key] = value
}
}
} | [
"func",
"(",
"p",
"*",
"Profile",
")",
"SetLabel",
"(",
"key",
"string",
",",
"value",
"[",
"]",
"string",
")",
"{",
"for",
"_",
",",
"sample",
":=",
"range",
"p",
".",
"Sample",
"{",
"if",
"sample",
".",
"Label",
"==",
"nil",
"{",
"sample",
".",... | // SetLabel sets the specified key to the specified value for all samples in the
// profile. | [
"SetLabel",
"sets",
"the",
"specified",
"key",
"to",
"the",
"specified",
"value",
"for",
"all",
"samples",
"in",
"the",
"profile",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L679-L687 | train |
google/pprof | profile/profile.go | RemoveLabel | func (p *Profile) RemoveLabel(key string) {
for _, sample := range p.Sample {
delete(sample.Label, key)
}
} | go | func (p *Profile) RemoveLabel(key string) {
for _, sample := range p.Sample {
delete(sample.Label, key)
}
} | [
"func",
"(",
"p",
"*",
"Profile",
")",
"RemoveLabel",
"(",
"key",
"string",
")",
"{",
"for",
"_",
",",
"sample",
":=",
"range",
"p",
".",
"Sample",
"{",
"delete",
"(",
"sample",
".",
"Label",
",",
"key",
")",
"\n",
"}",
"\n",
"}"
] | // RemoveLabel removes all labels associated with the specified key for all
// samples in the profile. | [
"RemoveLabel",
"removes",
"all",
"labels",
"associated",
"with",
"the",
"specified",
"key",
"for",
"all",
"samples",
"in",
"the",
"profile",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L691-L695 | train |
google/pprof | profile/profile.go | HasLabel | func (s *Sample) HasLabel(key, value string) bool {
for _, v := range s.Label[key] {
if v == value {
return true
}
}
return false
} | go | func (s *Sample) HasLabel(key, value string) bool {
for _, v := range s.Label[key] {
if v == value {
return true
}
}
return false
} | [
"func",
"(",
"s",
"*",
"Sample",
")",
"HasLabel",
"(",
"key",
",",
"value",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"s",
".",
"Label",
"[",
"key",
"]",
"{",
"if",
"v",
"==",
"value",
"{",
"return",
"true",
"\n",
"}",
... | // HasLabel returns true if a sample has a label with indicated key and value. | [
"HasLabel",
"returns",
"true",
"if",
"a",
"sample",
"has",
"a",
"label",
"with",
"indicated",
"key",
"and",
"value",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L698-L705 | train |
google/pprof | profile/profile.go | Scale | func (p *Profile) Scale(ratio float64) {
if ratio == 1 {
return
}
ratios := make([]float64, len(p.SampleType))
for i := range p.SampleType {
ratios[i] = ratio
}
p.ScaleN(ratios)
} | go | func (p *Profile) Scale(ratio float64) {
if ratio == 1 {
return
}
ratios := make([]float64, len(p.SampleType))
for i := range p.SampleType {
ratios[i] = ratio
}
p.ScaleN(ratios)
} | [
"func",
"(",
"p",
"*",
"Profile",
")",
"Scale",
"(",
"ratio",
"float64",
")",
"{",
"if",
"ratio",
"==",
"1",
"{",
"return",
"\n",
"}",
"\n",
"ratios",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"len",
"(",
"p",
".",
"SampleType",
")",
")",
"\... | // Scale multiplies all sample values in a profile by a constant. | [
"Scale",
"multiplies",
"all",
"sample",
"values",
"in",
"a",
"profile",
"by",
"a",
"constant",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L714-L723 | train |
google/pprof | profile/profile.go | ScaleN | func (p *Profile) ScaleN(ratios []float64) error {
if len(p.SampleType) != len(ratios) {
return fmt.Errorf("mismatched scale ratios, got %d, want %d", len(ratios), len(p.SampleType))
}
allOnes := true
for _, r := range ratios {
if r != 1 {
allOnes = false
break
}
}
if allOnes {
return nil
}
for _,... | go | func (p *Profile) ScaleN(ratios []float64) error {
if len(p.SampleType) != len(ratios) {
return fmt.Errorf("mismatched scale ratios, got %d, want %d", len(ratios), len(p.SampleType))
}
allOnes := true
for _, r := range ratios {
if r != 1 {
allOnes = false
break
}
}
if allOnes {
return nil
}
for _,... | [
"func",
"(",
"p",
"*",
"Profile",
")",
"ScaleN",
"(",
"ratios",
"[",
"]",
"float64",
")",
"error",
"{",
"if",
"len",
"(",
"p",
".",
"SampleType",
")",
"!=",
"len",
"(",
"ratios",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"... | // ScaleN multiplies each sample values in a sample by a different amount. | [
"ScaleN",
"multiplies",
"each",
"sample",
"values",
"in",
"a",
"sample",
"by",
"a",
"different",
"amount",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L726-L748 | train |
google/pprof | profile/profile.go | HasFunctions | func (p *Profile) HasFunctions() bool {
for _, l := range p.Location {
if l.Mapping != nil && !l.Mapping.HasFunctions {
return false
}
}
return true
} | go | func (p *Profile) HasFunctions() bool {
for _, l := range p.Location {
if l.Mapping != nil && !l.Mapping.HasFunctions {
return false
}
}
return true
} | [
"func",
"(",
"p",
"*",
"Profile",
")",
"HasFunctions",
"(",
")",
"bool",
"{",
"for",
"_",
",",
"l",
":=",
"range",
"p",
".",
"Location",
"{",
"if",
"l",
".",
"Mapping",
"!=",
"nil",
"&&",
"!",
"l",
".",
"Mapping",
".",
"HasFunctions",
"{",
"retur... | // HasFunctions determines if all locations in this profile have
// symbolized function information. | [
"HasFunctions",
"determines",
"if",
"all",
"locations",
"in",
"this",
"profile",
"have",
"symbolized",
"function",
"information",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L752-L759 | train |
google/pprof | profile/profile.go | HasFileLines | func (p *Profile) HasFileLines() bool {
for _, l := range p.Location {
if l.Mapping != nil && (!l.Mapping.HasFilenames || !l.Mapping.HasLineNumbers) {
return false
}
}
return true
} | go | func (p *Profile) HasFileLines() bool {
for _, l := range p.Location {
if l.Mapping != nil && (!l.Mapping.HasFilenames || !l.Mapping.HasLineNumbers) {
return false
}
}
return true
} | [
"func",
"(",
"p",
"*",
"Profile",
")",
"HasFileLines",
"(",
")",
"bool",
"{",
"for",
"_",
",",
"l",
":=",
"range",
"p",
".",
"Location",
"{",
"if",
"l",
".",
"Mapping",
"!=",
"nil",
"&&",
"(",
"!",
"l",
".",
"Mapping",
".",
"HasFilenames",
"||",
... | // HasFileLines determines if all locations in this profile have
// symbolized file and line number information. | [
"HasFileLines",
"determines",
"if",
"all",
"locations",
"in",
"this",
"profile",
"have",
"symbolized",
"file",
"and",
"line",
"number",
"information",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/profile.go#L763-L770 | train |
google/pprof | internal/binutils/addr2liner_nm.go | newAddr2LinerNM | func newAddr2LinerNM(cmd, file string, base uint64) (*addr2LinerNM, error) {
if cmd == "" {
cmd = defaultNM
}
var b bytes.Buffer
c := exec.Command(cmd, "-n", file)
c.Stdout = &b
if err := c.Run(); err != nil {
return nil, err
}
return parseAddr2LinerNM(base, &b)
} | go | func newAddr2LinerNM(cmd, file string, base uint64) (*addr2LinerNM, error) {
if cmd == "" {
cmd = defaultNM
}
var b bytes.Buffer
c := exec.Command(cmd, "-n", file)
c.Stdout = &b
if err := c.Run(); err != nil {
return nil, err
}
return parseAddr2LinerNM(base, &b)
} | [
"func",
"newAddr2LinerNM",
"(",
"cmd",
",",
"file",
"string",
",",
"base",
"uint64",
")",
"(",
"*",
"addr2LinerNM",
",",
"error",
")",
"{",
"if",
"cmd",
"==",
"\"",
"\"",
"{",
"cmd",
"=",
"defaultNM",
"\n",
"}",
"\n",
"var",
"b",
"bytes",
".",
"Buf... | // newAddr2LinerNM starts the given nm command reporting information about the
// given executable file. If file is a shared library, base should be
// the address at which it was mapped in the program under
// consideration. | [
"newAddr2LinerNM",
"starts",
"the",
"given",
"nm",
"command",
"reporting",
"information",
"about",
"the",
"given",
"executable",
"file",
".",
"If",
"file",
"is",
"a",
"shared",
"library",
"base",
"should",
"be",
"the",
"address",
"at",
"which",
"it",
"was",
... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/binutils/addr2liner_nm.go#L47-L58 | train |
google/pprof | internal/symbolz/symbolz.go | hasGperftoolsSuffix | func hasGperftoolsSuffix(path string) bool {
suffixes := []string{
"/pprof/heap",
"/pprof/growth",
"/pprof/profile",
"/pprof/pmuprofile",
"/pprof/contention",
}
for _, s := range suffixes {
if strings.HasSuffix(path, s) {
return true
}
}
return false
} | go | func hasGperftoolsSuffix(path string) bool {
suffixes := []string{
"/pprof/heap",
"/pprof/growth",
"/pprof/profile",
"/pprof/pmuprofile",
"/pprof/contention",
}
for _, s := range suffixes {
if strings.HasSuffix(path, s) {
return true
}
}
return false
} | [
"func",
"hasGperftoolsSuffix",
"(",
"path",
"string",
")",
"bool",
"{",
"suffixes",
":=",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"}",
"\n",
"for",
"_",
",",
"s",
":=",
"rang... | // hasGperftoolsSuffix checks whether path ends with one of the suffixes listed in
// pprof_remote_servers.html from the gperftools distribution | [
"hasGperftoolsSuffix",
"checks",
"whether",
"path",
"ends",
"with",
"one",
"of",
"the",
"suffixes",
"listed",
"in",
"pprof_remote_servers",
".",
"html",
"from",
"the",
"gperftools",
"distribution"
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/symbolz/symbolz.go#L73-L87 | train |
google/pprof | internal/symbolz/symbolz.go | symbolz | func symbolz(source string) string {
if url, err := url.Parse(source); err == nil && url.Host != "" {
// All paths in the net/http/pprof Go package contain /debug/pprof/
if strings.Contains(url.Path, "/debug/pprof/") || hasGperftoolsSuffix(url.Path) {
url.Path = path.Clean(url.Path + "/../symbol")
} else {
... | go | func symbolz(source string) string {
if url, err := url.Parse(source); err == nil && url.Host != "" {
// All paths in the net/http/pprof Go package contain /debug/pprof/
if strings.Contains(url.Path, "/debug/pprof/") || hasGperftoolsSuffix(url.Path) {
url.Path = path.Clean(url.Path + "/../symbol")
} else {
... | [
"func",
"symbolz",
"(",
"source",
"string",
")",
"string",
"{",
"if",
"url",
",",
"err",
":=",
"url",
".",
"Parse",
"(",
"source",
")",
";",
"err",
"==",
"nil",
"&&",
"url",
".",
"Host",
"!=",
"\"",
"\"",
"{",
"// All paths in the net/http/pprof Go packa... | // symbolz returns the corresponding symbolz source for a profile URL. | [
"symbolz",
"returns",
"the",
"corresponding",
"symbolz",
"source",
"for",
"a",
"profile",
"URL",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/symbolz/symbolz.go#L90-L103 | train |
google/pprof | internal/symbolz/symbolz.go | adjust | func adjust(addr uint64, offset int64) (uint64, bool) {
adj := uint64(int64(addr) + offset)
if offset < 0 {
if adj >= addr {
return 0, true
}
} else {
if adj < addr {
return 0, true
}
}
return adj, false
} | go | func adjust(addr uint64, offset int64) (uint64, bool) {
adj := uint64(int64(addr) + offset)
if offset < 0 {
if adj >= addr {
return 0, true
}
} else {
if adj < addr {
return 0, true
}
}
return adj, false
} | [
"func",
"adjust",
"(",
"addr",
"uint64",
",",
"offset",
"int64",
")",
"(",
"uint64",
",",
"bool",
")",
"{",
"adj",
":=",
"uint64",
"(",
"int64",
"(",
"addr",
")",
"+",
"offset",
")",
"\n",
"if",
"offset",
"<",
"0",
"{",
"if",
"adj",
">=",
"addr",... | // adjust shifts the specified address by the signed offset. It returns the
// adjusted address. It signals that the address cannot be adjusted without an
// overflow by returning true in the second return value. | [
"adjust",
"shifts",
"the",
"specified",
"address",
"by",
"the",
"signed",
"offset",
".",
"It",
"returns",
"the",
"adjusted",
"address",
".",
"It",
"signals",
"that",
"the",
"address",
"cannot",
"be",
"adjusted",
"without",
"an",
"overflow",
"by",
"returning",
... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/symbolz/symbolz.go#L188-L200 | train |
google/pprof | internal/driver/svg.go | massageSVG | func massageSVG(svg string) string {
// Work around for dot bug which misses quoting some ampersands,
// resulting on unparsable SVG.
svg = strings.Replace(svg, "&;", "&;", -1)
// Dot's SVG output is
//
// <svg width="___" height="___"
// viewBox="___" xmlns=...>
// <g id="graph0" transform="..."... | go | func massageSVG(svg string) string {
// Work around for dot bug which misses quoting some ampersands,
// resulting on unparsable SVG.
svg = strings.Replace(svg, "&;", "&;", -1)
// Dot's SVG output is
//
// <svg width="___" height="___"
// viewBox="___" xmlns=...>
// <g id="graph0" transform="..."... | [
"func",
"massageSVG",
"(",
"svg",
"string",
")",
"string",
"{",
"// Work around for dot bug which misses quoting some ampersands,",
"// resulting on unparsable SVG.",
"svg",
"=",
"strings",
".",
"Replace",
"(",
"svg",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"-",
"1",... | // massageSVG enhances the SVG output from DOT to provide better
// panning inside a web browser. It uses the svgpan library, which is
// embedded into the svgpan.JSSource variable. | [
"massageSVG",
"enhances",
"the",
"SVG",
"output",
"from",
"DOT",
"to",
"provide",
"better",
"panning",
"inside",
"a",
"web",
"browser",
".",
"It",
"uses",
"the",
"svgpan",
"library",
"which",
"is",
"embedded",
"into",
"the",
"svgpan",
".",
"JSSource",
"varia... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/svg.go#L33-L80 | train |
google/pprof | profile/legacy_profile.go | remapLocationIDs | func (p *Profile) remapLocationIDs() {
seen := make(map[*Location]bool, len(p.Location))
var locs []*Location
for _, s := range p.Sample {
for _, l := range s.Location {
if seen[l] {
continue
}
l.ID = uint64(len(locs) + 1)
locs = append(locs, l)
seen[l] = true
}
}
p.Location = locs
} | go | func (p *Profile) remapLocationIDs() {
seen := make(map[*Location]bool, len(p.Location))
var locs []*Location
for _, s := range p.Sample {
for _, l := range s.Location {
if seen[l] {
continue
}
l.ID = uint64(len(locs) + 1)
locs = append(locs, l)
seen[l] = true
}
}
p.Location = locs
} | [
"func",
"(",
"p",
"*",
"Profile",
")",
"remapLocationIDs",
"(",
")",
"{",
"seen",
":=",
"make",
"(",
"map",
"[",
"*",
"Location",
"]",
"bool",
",",
"len",
"(",
"p",
".",
"Location",
")",
")",
"\n",
"var",
"locs",
"[",
"]",
"*",
"Location",
"\n\n"... | // remapLocationIDs ensures there is a location for each address
// referenced by a sample, and remaps the samples to point to the new
// location ids. | [
"remapLocationIDs",
"ensures",
"there",
"is",
"a",
"location",
"for",
"each",
"address",
"referenced",
"by",
"a",
"sample",
"and",
"remaps",
"the",
"samples",
"to",
"point",
"to",
"the",
"new",
"location",
"ids",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/legacy_profile.go#L151-L166 | train |
google/pprof | profile/legacy_profile.go | parseContentionSample | func parseContentionSample(line string, period, cpuHz int64) (value []int64, addrs []uint64, err error) {
sampleData := contentionSampleRE.FindStringSubmatch(line)
if sampleData == nil {
return nil, nil, errUnrecognized
}
v1, err := strconv.ParseInt(sampleData[1], 10, 64)
if err != nil {
return nil, nil, fmt.... | go | func parseContentionSample(line string, period, cpuHz int64) (value []int64, addrs []uint64, err error) {
sampleData := contentionSampleRE.FindStringSubmatch(line)
if sampleData == nil {
return nil, nil, errUnrecognized
}
v1, err := strconv.ParseInt(sampleData[1], 10, 64)
if err != nil {
return nil, nil, fmt.... | [
"func",
"parseContentionSample",
"(",
"line",
"string",
",",
"period",
",",
"cpuHz",
"int64",
")",
"(",
"value",
"[",
"]",
"int64",
",",
"addrs",
"[",
"]",
"uint64",
",",
"err",
"error",
")",
"{",
"sampleData",
":=",
"contentionSampleRE",
".",
"FindStringS... | // parseContentionSample parses a single row from a contention profile
// into a new Sample. | [
"parseContentionSample",
"parses",
"a",
"single",
"row",
"from",
"a",
"contention",
"profile",
"into",
"a",
"new",
"Sample",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/legacy_profile.go#L800-L833 | train |
google/pprof | profile/legacy_profile.go | removeLoggingInfo | func removeLoggingInfo(line string) string {
if match := logInfoRE.FindStringIndex(line); match != nil {
return line[match[1]:]
}
return line
} | go | func removeLoggingInfo(line string) string {
if match := logInfoRE.FindStringIndex(line); match != nil {
return line[match[1]:]
}
return line
} | [
"func",
"removeLoggingInfo",
"(",
"line",
"string",
")",
"string",
"{",
"if",
"match",
":=",
"logInfoRE",
".",
"FindStringIndex",
"(",
"line",
")",
";",
"match",
"!=",
"nil",
"{",
"return",
"line",
"[",
"match",
"[",
"1",
"]",
":",
"]",
"\n",
"}",
"\... | // removeLoggingInfo detects and removes log prefix entries generated
// by the glog package. If no logging prefix is detected, the string
// is returned unmodified. | [
"removeLoggingInfo",
"detects",
"and",
"removes",
"log",
"prefix",
"entries",
"generated",
"by",
"the",
"glog",
"package",
".",
"If",
"no",
"logging",
"prefix",
"is",
"detected",
"the",
"string",
"is",
"returned",
"unmodified",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/legacy_profile.go#L1010-L1015 | train |
google/pprof | profile/legacy_profile.go | isMemoryMapSentinel | func isMemoryMapSentinel(line string) bool {
for _, s := range memoryMapSentinels {
if strings.Contains(line, s) {
return true
}
}
return false
} | go | func isMemoryMapSentinel(line string) bool {
for _, s := range memoryMapSentinels {
if strings.Contains(line, s) {
return true
}
}
return false
} | [
"func",
"isMemoryMapSentinel",
"(",
"line",
"string",
")",
"bool",
"{",
"for",
"_",
",",
"s",
":=",
"range",
"memoryMapSentinels",
"{",
"if",
"strings",
".",
"Contains",
"(",
"line",
",",
"s",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"}",
"\n",
"... | // isMemoryMapSentinel returns true if the string contains one of the
// known sentinels for memory map information. | [
"isMemoryMapSentinel",
"returns",
"true",
"if",
"the",
"string",
"contains",
"one",
"of",
"the",
"known",
"sentinels",
"for",
"memory",
"map",
"information",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/legacy_profile.go#L1081-L1088 | train |
google/pprof | profile/legacy_java_profile.go | javaCPUProfile | func javaCPUProfile(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 er... | go | func javaCPUProfile(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 er... | [
"func",
"javaCPUProfile",
"(",
"b",
"[",
"]",
"byte",
",",
"period",
"int64",
",",
"parse",
"func",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"uint64",
",",
"[",
"]",
"byte",
")",
")",
"(",
"*",
"Profile",
",",
"error",
")",
"{",
"p",
":=",
"&",
... | // javaCPUProfile returns a new Profile from 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. | [
"javaCPUProfile",
"returns",
"a",
"new",
"Profile",
"from",
"profilez",
"data",
".",
"b",
"is",
"the",
"profile",
"bytes",
"after",
"the",
"header",
"period",
"is",
"the",
"profiling",
"period",
"and",
"parse",
"is",
"a",
"function",
"to",
"parse",
"8",
"-... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/legacy_java_profile.go#L42-L64 | train |
google/pprof | profile/legacy_java_profile.go | parseJavaProfile | func parseJavaProfile(b []byte) (*Profile, error) {
h := bytes.SplitAfterN(b, []byte("\n"), 2)
if len(h) < 2 {
return nil, errUnrecognized
}
p := &Profile{
PeriodType: &ValueType{},
}
header := string(bytes.TrimSpace(h[0]))
var err error
var pType string
switch header {
case "--- heapz 1 ---":
pType =... | go | func parseJavaProfile(b []byte) (*Profile, error) {
h := bytes.SplitAfterN(b, []byte("\n"), 2)
if len(h) < 2 {
return nil, errUnrecognized
}
p := &Profile{
PeriodType: &ValueType{},
}
header := string(bytes.TrimSpace(h[0]))
var err error
var pType string
switch header {
case "--- heapz 1 ---":
pType =... | [
"func",
"parseJavaProfile",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"*",
"Profile",
",",
"error",
")",
"{",
"h",
":=",
"bytes",
".",
"SplitAfterN",
"(",
"b",
",",
"[",
"]",
"byte",
"(",
"\"",
"\\n",
"\"",
")",
",",
"2",
")",
"\n",
"if",
"len",
... | // parseJavaProfile returns a new profile from heapz or contentionz
// data. b is the profile bytes after the header. | [
"parseJavaProfile",
"returns",
"a",
"new",
"profile",
"from",
"heapz",
"or",
"contentionz",
"data",
".",
"b",
"is",
"the",
"profile",
"bytes",
"after",
"the",
"header",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/legacy_java_profile.go#L68-L107 | train |
google/pprof | profile/legacy_java_profile.go | parseJavaHeader | func parseJavaHeader(pType string, b []byte, p *Profile) ([]byte, error) {
nextNewLine := bytes.IndexByte(b, byte('\n'))
for nextNewLine != -1 {
line := string(bytes.TrimSpace(b[0:nextNewLine]))
if line != "" {
h := attributeRx.FindStringSubmatch(line)
if h == nil {
// Not a valid attribute, exit.
r... | go | func parseJavaHeader(pType string, b []byte, p *Profile) ([]byte, error) {
nextNewLine := bytes.IndexByte(b, byte('\n'))
for nextNewLine != -1 {
line := string(bytes.TrimSpace(b[0:nextNewLine]))
if line != "" {
h := attributeRx.FindStringSubmatch(line)
if h == nil {
// Not a valid attribute, exit.
r... | [
"func",
"parseJavaHeader",
"(",
"pType",
"string",
",",
"b",
"[",
"]",
"byte",
",",
"p",
"*",
"Profile",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"nextNewLine",
":=",
"bytes",
".",
"IndexByte",
"(",
"b",
",",
"byte",
"(",
"'\\n'",
")",
... | // parseJavaHeader parses the attribute section on a java profile and
// populates a profile. Returns the remainder of the buffer after all
// attributes. | [
"parseJavaHeader",
"parses",
"the",
"attribute",
"section",
"on",
"a",
"java",
"profile",
"and",
"populates",
"a",
"profile",
".",
"Returns",
"the",
"remainder",
"of",
"the",
"buffer",
"after",
"all",
"attributes",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/legacy_java_profile.go#L112-L162 | train |
google/pprof | profile/legacy_java_profile.go | parseJavaLocations | func parseJavaLocations(b []byte, locs map[uint64]*Location, p *Profile) error {
r := bytes.NewBuffer(b)
fns := make(map[string]*Function)
for {
line, err := r.ReadString('\n')
if err != nil {
if err != io.EOF {
return err
}
if line == "" {
break
}
}
if line = strings.TrimSpace(line); li... | go | func parseJavaLocations(b []byte, locs map[uint64]*Location, p *Profile) error {
r := bytes.NewBuffer(b)
fns := make(map[string]*Function)
for {
line, err := r.ReadString('\n')
if err != nil {
if err != io.EOF {
return err
}
if line == "" {
break
}
}
if line = strings.TrimSpace(line); li... | [
"func",
"parseJavaLocations",
"(",
"b",
"[",
"]",
"byte",
",",
"locs",
"map",
"[",
"uint64",
"]",
"*",
"Location",
",",
"p",
"*",
"Profile",
")",
"error",
"{",
"r",
":=",
"bytes",
".",
"NewBuffer",
"(",
"b",
")",
"\n",
"fns",
":=",
"make",
"(",
"... | // parseJavaLocations parses the location information in a java
// profile and populates the Locations in a profile. It uses the
// location addresses from the profile as both the ID of each
// location. | [
"parseJavaLocations",
"parses",
"the",
"location",
"information",
"in",
"a",
"java",
"profile",
"and",
"populates",
"the",
"Locations",
"in",
"a",
"profile",
".",
"It",
"uses",
"the",
"location",
"addresses",
"from",
"the",
"profile",
"as",
"both",
"the",
"ID"... | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/legacy_java_profile.go#L239-L315 | train |
google/pprof | profile/prune.go | simplifyFunc | func simplifyFunc(f string) string {
// Account for leading '.' on the PPC ELF v1 ABI.
funcName := strings.TrimPrefix(f, ".")
// Account for unsimplified names -- try to remove the argument list by trimming
// starting from the first '(', but skipping reserved names that have '('.
for _, ind := range bracketRx.Fi... | go | func simplifyFunc(f string) string {
// Account for leading '.' on the PPC ELF v1 ABI.
funcName := strings.TrimPrefix(f, ".")
// Account for unsimplified names -- try to remove the argument list by trimming
// starting from the first '(', but skipping reserved names that have '('.
for _, ind := range bracketRx.Fi... | [
"func",
"simplifyFunc",
"(",
"f",
"string",
")",
"string",
"{",
"// Account for leading '.' on the PPC ELF v1 ABI.",
"funcName",
":=",
"strings",
".",
"TrimPrefix",
"(",
"f",
",",
"\"",
"\"",
")",
"\n",
"// Account for unsimplified names -- try to remove the argument list ... | // simplifyFunc does some primitive simplification of function names. | [
"simplifyFunc",
"does",
"some",
"primitive",
"simplification",
"of",
"function",
"names",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/prune.go#L37-L56 | train |
google/pprof | profile/prune.go | RemoveUninteresting | func (p *Profile) RemoveUninteresting() error {
var keep, drop *regexp.Regexp
var err error
if p.DropFrames != "" {
if drop, err = regexp.Compile("^(" + p.DropFrames + ")$"); err != nil {
return fmt.Errorf("failed to compile regexp %s: %v", p.DropFrames, err)
}
if p.KeepFrames != "" {
if keep, err = reg... | go | func (p *Profile) RemoveUninteresting() error {
var keep, drop *regexp.Regexp
var err error
if p.DropFrames != "" {
if drop, err = regexp.Compile("^(" + p.DropFrames + ")$"); err != nil {
return fmt.Errorf("failed to compile regexp %s: %v", p.DropFrames, err)
}
if p.KeepFrames != "" {
if keep, err = reg... | [
"func",
"(",
"p",
"*",
"Profile",
")",
"RemoveUninteresting",
"(",
")",
"error",
"{",
"var",
"keep",
",",
"drop",
"*",
"regexp",
".",
"Regexp",
"\n",
"var",
"err",
"error",
"\n\n",
"if",
"p",
".",
"DropFrames",
"!=",
"\"",
"\"",
"{",
"if",
"drop",
... | // RemoveUninteresting prunes and elides profiles using built-in
// tables of uninteresting function names. | [
"RemoveUninteresting",
"prunes",
"and",
"elides",
"profiles",
"using",
"built",
"-",
"in",
"tables",
"of",
"uninteresting",
"function",
"names",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/profile/prune.go#L121-L137 | train |
google/pprof | internal/driver/options.go | setDefaults | func setDefaults(o *plugin.Options) *plugin.Options {
d := &plugin.Options{}
if o != nil {
*d = *o
}
if d.Writer == nil {
d.Writer = oswriter{}
}
if d.Flagset == nil {
d.Flagset = &GoFlags{}
}
if d.Obj == nil {
d.Obj = &binutils.Binutils{}
}
if d.UI == nil {
d.UI = &stdUI{r: bufio.NewReader(os.Stdin... | go | func setDefaults(o *plugin.Options) *plugin.Options {
d := &plugin.Options{}
if o != nil {
*d = *o
}
if d.Writer == nil {
d.Writer = oswriter{}
}
if d.Flagset == nil {
d.Flagset = &GoFlags{}
}
if d.Obj == nil {
d.Obj = &binutils.Binutils{}
}
if d.UI == nil {
d.UI = &stdUI{r: bufio.NewReader(os.Stdin... | [
"func",
"setDefaults",
"(",
"o",
"*",
"plugin",
".",
"Options",
")",
"*",
"plugin",
".",
"Options",
"{",
"d",
":=",
"&",
"plugin",
".",
"Options",
"{",
"}",
"\n",
"if",
"o",
"!=",
"nil",
"{",
"*",
"d",
"=",
"*",
"o",
"\n",
"}",
"\n",
"if",
"d... | // setDefaults returns a new plugin.Options with zero fields sets to
// sensible defaults. | [
"setDefaults",
"returns",
"a",
"new",
"plugin",
".",
"Options",
"with",
"zero",
"fields",
"sets",
"to",
"sensible",
"defaults",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/options.go#L32-L56 | train |
google/pprof | internal/driver/interactive.go | interactive | func interactive(p *profile.Profile, o *plugin.Options) error {
// Enter command processing loop.
o.UI.SetAutoComplete(newCompleter(functionNames(p)))
pprofVariables.set("compact_labels", "true")
pprofVariables["sample_index"].help += fmt.Sprintf("Or use sample_index=name, with name in %v.\n", sampleTypes(p))
// ... | go | func interactive(p *profile.Profile, o *plugin.Options) error {
// Enter command processing loop.
o.UI.SetAutoComplete(newCompleter(functionNames(p)))
pprofVariables.set("compact_labels", "true")
pprofVariables["sample_index"].help += fmt.Sprintf("Or use sample_index=name, with name in %v.\n", sampleTypes(p))
// ... | [
"func",
"interactive",
"(",
"p",
"*",
"profile",
".",
"Profile",
",",
"o",
"*",
"plugin",
".",
"Options",
")",
"error",
"{",
"// Enter command processing loop.",
"o",
".",
"UI",
".",
"SetAutoComplete",
"(",
"newCompleter",
"(",
"functionNames",
"(",
"p",
")"... | // interactive starts a shell to read pprof commands. | [
"interactive",
"starts",
"a",
"shell",
"to",
"read",
"pprof",
"commands",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/interactive.go#L34-L125 | train |
google/pprof | internal/driver/interactive.go | groupOptions | func groupOptions(vars variables) map[string][]string {
groups := make(map[string][]string)
for name, option := range vars {
group := option.group
if group != "" {
groups[group] = append(groups[group], name)
}
}
for _, names := range groups {
sort.Strings(names)
}
return groups
} | go | func groupOptions(vars variables) map[string][]string {
groups := make(map[string][]string)
for name, option := range vars {
group := option.group
if group != "" {
groups[group] = append(groups[group], name)
}
}
for _, names := range groups {
sort.Strings(names)
}
return groups
} | [
"func",
"groupOptions",
"(",
"vars",
"variables",
")",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
"{",
"groups",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"\n",
"for",
"name",
",",
"option",
":=",
"range",
"vars",
"... | // groupOptions returns a map containing all non-empty groups
// mapped to an array of the option names in that group in
// sorted order. | [
"groupOptions",
"returns",
"a",
"map",
"containing",
"all",
"non",
"-",
"empty",
"groups",
"mapped",
"to",
"an",
"array",
"of",
"the",
"option",
"names",
"in",
"that",
"group",
"in",
"sorted",
"order",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/interactive.go#L130-L142 | train |
google/pprof | internal/driver/interactive.go | greetings | func greetings(p *profile.Profile, ui plugin.UI) {
numLabelUnits := identifyNumLabelUnits(p, ui)
ropt, err := reportOptions(p, numLabelUnits, pprofVariables)
if err == nil {
rpt := report.New(p, ropt)
ui.Print(strings.Join(report.ProfileLabels(rpt), "\n"))
if rpt.Total() == 0 && len(p.SampleType) > 1 {
ui.P... | go | func greetings(p *profile.Profile, ui plugin.UI) {
numLabelUnits := identifyNumLabelUnits(p, ui)
ropt, err := reportOptions(p, numLabelUnits, pprofVariables)
if err == nil {
rpt := report.New(p, ropt)
ui.Print(strings.Join(report.ProfileLabels(rpt), "\n"))
if rpt.Total() == 0 && len(p.SampleType) > 1 {
ui.P... | [
"func",
"greetings",
"(",
"p",
"*",
"profile",
".",
"Profile",
",",
"ui",
"plugin",
".",
"UI",
")",
"{",
"numLabelUnits",
":=",
"identifyNumLabelUnits",
"(",
"p",
",",
"ui",
")",
"\n",
"ropt",
",",
"err",
":=",
"reportOptions",
"(",
"p",
",",
"numLabel... | // greetings prints a brief welcome and some overall profile
// information before accepting interactive commands. | [
"greetings",
"prints",
"a",
"brief",
"welcome",
"and",
"some",
"overall",
"profile",
"information",
"before",
"accepting",
"interactive",
"commands",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/interactive.go#L148-L160 | train |
google/pprof | internal/driver/interactive.go | profileShortcuts | func profileShortcuts(p *profile.Profile) shortcuts {
s := pprofShortcuts
// Add shortcuts for sample types
for _, st := range p.SampleType {
command := fmt.Sprintf("sample_index=%s", st.Type)
s[st.Type] = []string{command}
s["total_"+st.Type] = []string{"mean=0", command}
s["mean_"+st.Type] = []string{"mean... | go | func profileShortcuts(p *profile.Profile) shortcuts {
s := pprofShortcuts
// Add shortcuts for sample types
for _, st := range p.SampleType {
command := fmt.Sprintf("sample_index=%s", st.Type)
s[st.Type] = []string{command}
s["total_"+st.Type] = []string{"mean=0", command}
s["mean_"+st.Type] = []string{"mean... | [
"func",
"profileShortcuts",
"(",
"p",
"*",
"profile",
".",
"Profile",
")",
"shortcuts",
"{",
"s",
":=",
"pprofShortcuts",
"\n",
"// Add shortcuts for sample types",
"for",
"_",
",",
"st",
":=",
"range",
"p",
".",
"SampleType",
"{",
"command",
":=",
"fmt",
".... | // profileShortcuts creates macros for convenience and backward compatibility. | [
"profileShortcuts",
"creates",
"macros",
"for",
"convenience",
"and",
"backward",
"compatibility",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/interactive.go#L181-L191 | train |
google/pprof | internal/driver/interactive.go | parseCommandLine | func parseCommandLine(input []string) ([]string, variables, error) {
cmd, args := input[:1], input[1:]
name := cmd[0]
c := pprofCommands[name]
if c == nil {
// Attempt splitting digits on abbreviated commands (eg top10)
if d := tailDigitsRE.FindString(name); d != "" && d != name {
name = name[:len(name)-len... | go | func parseCommandLine(input []string) ([]string, variables, error) {
cmd, args := input[:1], input[1:]
name := cmd[0]
c := pprofCommands[name]
if c == nil {
// Attempt splitting digits on abbreviated commands (eg top10)
if d := tailDigitsRE.FindString(name); d != "" && d != name {
name = name[:len(name)-len... | [
"func",
"parseCommandLine",
"(",
"input",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"string",
",",
"variables",
",",
"error",
")",
"{",
"cmd",
",",
"args",
":=",
"input",
"[",
":",
"1",
"]",
",",
"input",
"[",
"1",
":",
"]",
"\n",
"name",
":=",
"... | // parseCommandLine parses a command and returns the pprof command to
// execute and a set of variables for the report. | [
"parseCommandLine",
"parses",
"a",
"command",
"and",
"returns",
"the",
"pprof",
"command",
"to",
"execute",
"and",
"a",
"set",
"of",
"variables",
"for",
"the",
"report",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/interactive.go#L256-L324 | train |
google/pprof | internal/driver/interactive.go | commandHelp | func commandHelp(args string, ui plugin.UI) {
if args == "" {
help := usage(false)
help = help + `
: Clear focus/ignore/hide/tagfocus/tagignore
type "help <cmd|option>" for more information
`
ui.Print(help)
return
}
if c := pprofCommands[args]; c != nil {
ui.Print(c.help(args))
return
}
if v ... | go | func commandHelp(args string, ui plugin.UI) {
if args == "" {
help := usage(false)
help = help + `
: Clear focus/ignore/hide/tagfocus/tagignore
type "help <cmd|option>" for more information
`
ui.Print(help)
return
}
if c := pprofCommands[args]; c != nil {
ui.Print(c.help(args))
return
}
if v ... | [
"func",
"commandHelp",
"(",
"args",
"string",
",",
"ui",
"plugin",
".",
"UI",
")",
"{",
"if",
"args",
"==",
"\"",
"\"",
"{",
"help",
":=",
"usage",
"(",
"false",
")",
"\n",
"help",
"=",
"help",
"+",
"`\n : Clear focus/ignore/hide/tagfocus/tagignore\n\n t... | // commandHelp displays help and usage information for all Commands
// and Variables or a specific Command or Variable. | [
"commandHelp",
"displays",
"help",
"and",
"usage",
"information",
"for",
"all",
"Commands",
"and",
"Variables",
"or",
"a",
"specific",
"Command",
"or",
"Variable",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/interactive.go#L347-L371 | train |
google/pprof | internal/driver/interactive.go | newCompleter | func newCompleter(fns []string) func(string) string {
return func(line string) string {
v := pprofVariables
switch tokens := strings.Fields(line); len(tokens) {
case 0:
// Nothing to complete
case 1:
// Single token -- complete command name
if match := matchVariableOrCommand(v, tokens[0]); match != ""... | go | func newCompleter(fns []string) func(string) string {
return func(line string) string {
v := pprofVariables
switch tokens := strings.Fields(line); len(tokens) {
case 0:
// Nothing to complete
case 1:
// Single token -- complete command name
if match := matchVariableOrCommand(v, tokens[0]); match != ""... | [
"func",
"newCompleter",
"(",
"fns",
"[",
"]",
"string",
")",
"func",
"(",
"string",
")",
"string",
"{",
"return",
"func",
"(",
"line",
"string",
")",
"string",
"{",
"v",
":=",
"pprofVariables",
"\n",
"switch",
"tokens",
":=",
"strings",
".",
"Fields",
... | // newCompleter creates an autocompletion function for a set of commands. | [
"newCompleter",
"creates",
"an",
"autocompletion",
"function",
"for",
"a",
"set",
"of",
"commands",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/interactive.go#L374-L408 | train |
google/pprof | internal/driver/interactive.go | matchVariableOrCommand | func matchVariableOrCommand(v variables, token string) string {
token = strings.ToLower(token)
found := ""
for cmd := range pprofCommands {
if strings.HasPrefix(cmd, token) {
if found != "" {
return ""
}
found = cmd
}
}
for variable := range v {
if strings.HasPrefix(variable, token) {
if foun... | go | func matchVariableOrCommand(v variables, token string) string {
token = strings.ToLower(token)
found := ""
for cmd := range pprofCommands {
if strings.HasPrefix(cmd, token) {
if found != "" {
return ""
}
found = cmd
}
}
for variable := range v {
if strings.HasPrefix(variable, token) {
if foun... | [
"func",
"matchVariableOrCommand",
"(",
"v",
"variables",
",",
"token",
"string",
")",
"string",
"{",
"token",
"=",
"strings",
".",
"ToLower",
"(",
"token",
")",
"\n",
"found",
":=",
"\"",
"\"",
"\n",
"for",
"cmd",
":=",
"range",
"pprofCommands",
"{",
"if... | // matchVariableOrCommand attempts to match a string token to the prefix of a Command. | [
"matchVariableOrCommand",
"attempts",
"to",
"match",
"a",
"string",
"token",
"to",
"the",
"prefix",
"of",
"a",
"Command",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/driver/interactive.go#L411-L431 | train |
google/pprof | internal/measurement/measurement.go | ScaleProfiles | func ScaleProfiles(profiles []*profile.Profile) error {
if len(profiles) == 0 {
return nil
}
periodTypes := make([]*profile.ValueType, 0, len(profiles))
for _, p := range profiles {
if p.PeriodType != nil {
periodTypes = append(periodTypes, p.PeriodType)
}
}
periodType, err := CommonValueType(periodTypes... | go | func ScaleProfiles(profiles []*profile.Profile) error {
if len(profiles) == 0 {
return nil
}
periodTypes := make([]*profile.ValueType, 0, len(profiles))
for _, p := range profiles {
if p.PeriodType != nil {
periodTypes = append(periodTypes, p.PeriodType)
}
}
periodType, err := CommonValueType(periodTypes... | [
"func",
"ScaleProfiles",
"(",
"profiles",
"[",
"]",
"*",
"profile",
".",
"Profile",
")",
"error",
"{",
"if",
"len",
"(",
"profiles",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"periodTypes",
":=",
"make",
"(",
"[",
"]",
"*",
"profile",
... | // ScaleProfiles updates the units in a set of profiles to make them
// compatible. It scales the profiles to the smallest unit to preserve
// data. | [
"ScaleProfiles",
"updates",
"the",
"units",
"in",
"a",
"set",
"of",
"profiles",
"to",
"make",
"them",
"compatible",
".",
"It",
"scales",
"the",
"profiles",
"to",
"the",
"smallest",
"unit",
"to",
"preserve",
"data",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/measurement/measurement.go#L30-L83 | train |
google/pprof | internal/measurement/measurement.go | CommonValueType | func CommonValueType(ts []*profile.ValueType) (*profile.ValueType, error) {
if len(ts) <= 1 {
return nil, nil
}
minType := ts[0]
for _, t := range ts[1:] {
if !compatibleValueTypes(minType, t) {
return nil, fmt.Errorf("incompatible types: %v %v", *minType, *t)
}
if ratio, _ := Scale(1, t.Unit, minType.Un... | go | func CommonValueType(ts []*profile.ValueType) (*profile.ValueType, error) {
if len(ts) <= 1 {
return nil, nil
}
minType := ts[0]
for _, t := range ts[1:] {
if !compatibleValueTypes(minType, t) {
return nil, fmt.Errorf("incompatible types: %v %v", *minType, *t)
}
if ratio, _ := Scale(1, t.Unit, minType.Un... | [
"func",
"CommonValueType",
"(",
"ts",
"[",
"]",
"*",
"profile",
".",
"ValueType",
")",
"(",
"*",
"profile",
".",
"ValueType",
",",
"error",
")",
"{",
"if",
"len",
"(",
"ts",
")",
"<=",
"1",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"minT... | // CommonValueType returns the finest type from a set of compatible
// types. | [
"CommonValueType",
"returns",
"the",
"finest",
"type",
"from",
"a",
"set",
"of",
"compatible",
"types",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/measurement/measurement.go#L87-L102 | train |
google/pprof | internal/measurement/measurement.go | Percentage | func Percentage(value, total int64) string {
var ratio float64
if total != 0 {
ratio = math.Abs(float64(value)/float64(total)) * 100
}
switch {
case math.Abs(ratio) >= 99.95 && math.Abs(ratio) <= 100.05:
return " 100%"
case math.Abs(ratio) >= 1.0:
return fmt.Sprintf("%5.2f%%", ratio)
default:
return fmt... | go | func Percentage(value, total int64) string {
var ratio float64
if total != 0 {
ratio = math.Abs(float64(value)/float64(total)) * 100
}
switch {
case math.Abs(ratio) >= 99.95 && math.Abs(ratio) <= 100.05:
return " 100%"
case math.Abs(ratio) >= 1.0:
return fmt.Sprintf("%5.2f%%", ratio)
default:
return fmt... | [
"func",
"Percentage",
"(",
"value",
",",
"total",
"int64",
")",
"string",
"{",
"var",
"ratio",
"float64",
"\n",
"if",
"total",
"!=",
"0",
"{",
"ratio",
"=",
"math",
".",
"Abs",
"(",
"float64",
"(",
"value",
")",
"/",
"float64",
"(",
"total",
")",
"... | // Percentage computes the percentage of total of a value, and encodes
// it as a string. At least two digits of precision are printed. | [
"Percentage",
"computes",
"the",
"percentage",
"of",
"total",
"of",
"a",
"value",
"and",
"encodes",
"it",
"as",
"a",
"string",
".",
"At",
"least",
"two",
"digits",
"of",
"precision",
"are",
"printed",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/measurement/measurement.go#L160-L173 | train |
google/pprof | internal/measurement/measurement.go | isMemoryUnit | func isMemoryUnit(unit string) bool {
switch strings.TrimSuffix(strings.ToLower(unit), "s") {
case "byte", "b", "kilobyte", "kb", "megabyte", "mb", "gigabyte", "gb":
return true
}
return false
} | go | func isMemoryUnit(unit string) bool {
switch strings.TrimSuffix(strings.ToLower(unit), "s") {
case "byte", "b", "kilobyte", "kb", "megabyte", "mb", "gigabyte", "gb":
return true
}
return false
} | [
"func",
"isMemoryUnit",
"(",
"unit",
"string",
")",
"bool",
"{",
"switch",
"strings",
".",
"TrimSuffix",
"(",
"strings",
".",
"ToLower",
"(",
"unit",
")",
",",
"\"",
"\"",
")",
"{",
"case",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
... | // isMemoryUnit returns whether a name is recognized as a memory size
// unit. | [
"isMemoryUnit",
"returns",
"whether",
"a",
"name",
"is",
"recognized",
"as",
"a",
"memory",
"size",
"unit",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/measurement/measurement.go#L177-L183 | train |
google/pprof | internal/measurement/measurement.go | isTimeUnit | func isTimeUnit(unit string) bool {
unit = strings.ToLower(unit)
if len(unit) > 2 {
unit = strings.TrimSuffix(unit, "s")
}
switch unit {
case "nanosecond", "ns", "microsecond", "millisecond", "ms", "s", "second", "sec", "hr", "day", "week", "year":
return true
}
return false
} | go | func isTimeUnit(unit string) bool {
unit = strings.ToLower(unit)
if len(unit) > 2 {
unit = strings.TrimSuffix(unit, "s")
}
switch unit {
case "nanosecond", "ns", "microsecond", "millisecond", "ms", "s", "second", "sec", "hr", "day", "week", "year":
return true
}
return false
} | [
"func",
"isTimeUnit",
"(",
"unit",
"string",
")",
"bool",
"{",
"unit",
"=",
"strings",
".",
"ToLower",
"(",
"unit",
")",
"\n",
"if",
"len",
"(",
"unit",
")",
">",
"2",
"{",
"unit",
"=",
"strings",
".",
"TrimSuffix",
"(",
"unit",
",",
"\"",
"\"",
... | // isTimeUnit returns whether a name is recognized as a time unit. | [
"isTimeUnit",
"returns",
"whether",
"a",
"name",
"is",
"recognized",
"as",
"a",
"time",
"unit",
"."
] | 8358a9778bd1e48718ffcb96eb11ee061385bf62 | https://github.com/google/pprof/blob/8358a9778bd1e48718ffcb96eb11ee061385bf62/internal/measurement/measurement.go#L241-L252 | train |
kubernetes-retired/contrib | scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/writerc.go | yaml_emitter_set_writer_error | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool {
emitter.error = yaml_WRITER_ERROR
emitter.problem = problem
return false
} | go | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool {
emitter.error = yaml_WRITER_ERROR
emitter.problem = problem
return false
} | [
"func",
"yaml_emitter_set_writer_error",
"(",
"emitter",
"*",
"yaml_emitter_t",
",",
"problem",
"string",
")",
"bool",
"{",
"emitter",
".",
"error",
"=",
"yaml_WRITER_ERROR",
"\n",
"emitter",
".",
"problem",
"=",
"problem",
"\n",
"return",
"false",
"\n",
"}"
] | // Set the writer error and return false. | [
"Set",
"the",
"writer",
"error",
"and",
"return",
"false",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/scale-demo/Godeps/_workspace/src/gopkg.in/yaml.v2/writerc.go#L4-L8 | train |
kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/podsecuritypolicy.go | List | func (s *podSecurityPolicy) List(opts api.ListOptions) (*extensions.PodSecurityPolicyList, error) {
result := &extensions.PodSecurityPolicyList{}
err := s.client.Get().
Resource("podsecuritypolicies").
VersionedParams(&opts, api.ParameterCodec).
Do().
Into(result)
return result, err
} | go | func (s *podSecurityPolicy) List(opts api.ListOptions) (*extensions.PodSecurityPolicyList, error) {
result := &extensions.PodSecurityPolicyList{}
err := s.client.Get().
Resource("podsecuritypolicies").
VersionedParams(&opts, api.ParameterCodec).
Do().
Into(result)
return result, err
} | [
"func",
"(",
"s",
"*",
"podSecurityPolicy",
")",
"List",
"(",
"opts",
"api",
".",
"ListOptions",
")",
"(",
"*",
"extensions",
".",
"PodSecurityPolicyList",
",",
"error",
")",
"{",
"result",
":=",
"&",
"extensions",
".",
"PodSecurityPolicyList",
"{",
"}",
"... | // List returns a list of PodSecurityPolicies matching the selectors. | [
"List",
"returns",
"a",
"list",
"of",
"PodSecurityPolicies",
"matching",
"the",
"selectors",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/podsecuritypolicy.go#L60-L70 | train |
kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/podsecuritypolicy.go | Get | func (s *podSecurityPolicy) Get(name string) (*extensions.PodSecurityPolicy, error) {
result := &extensions.PodSecurityPolicy{}
err := s.client.Get().
Resource("podsecuritypolicies").
Name(name).
Do().
Into(result)
return result, err
} | go | func (s *podSecurityPolicy) Get(name string) (*extensions.PodSecurityPolicy, error) {
result := &extensions.PodSecurityPolicy{}
err := s.client.Get().
Resource("podsecuritypolicies").
Name(name).
Do().
Into(result)
return result, err
} | [
"func",
"(",
"s",
"*",
"podSecurityPolicy",
")",
"Get",
"(",
"name",
"string",
")",
"(",
"*",
"extensions",
".",
"PodSecurityPolicy",
",",
"error",
")",
"{",
"result",
":=",
"&",
"extensions",
".",
"PodSecurityPolicy",
"{",
"}",
"\n",
"err",
":=",
"s",
... | // Get returns the given PodSecurityPolicy, or an error. | [
"Get",
"returns",
"the",
"given",
"PodSecurityPolicy",
"or",
"an",
"error",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/podsecuritypolicy.go#L73-L82 | train |
kubernetes-retired/contrib | service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/podsecuritypolicy.go | Watch | func (s *podSecurityPolicy) Watch(opts api.ListOptions) (watch.Interface, error) {
return s.client.Get().
Prefix("watch").
Resource("podsecuritypolicies").
VersionedParams(&opts, api.ParameterCodec).
Watch()
} | go | func (s *podSecurityPolicy) Watch(opts api.ListOptions) (watch.Interface, error) {
return s.client.Get().
Prefix("watch").
Resource("podsecuritypolicies").
VersionedParams(&opts, api.ParameterCodec).
Watch()
} | [
"func",
"(",
"s",
"*",
"podSecurityPolicy",
")",
"Watch",
"(",
"opts",
"api",
".",
"ListOptions",
")",
"(",
"watch",
".",
"Interface",
",",
"error",
")",
"{",
"return",
"s",
".",
"client",
".",
"Get",
"(",
")",
".",
"Prefix",
"(",
"\"",
"\"",
")",
... | // Watch starts watching for PodSecurityPolicies matching the given selectors. | [
"Watch",
"starts",
"watching",
"for",
"PodSecurityPolicies",
"matching",
"the",
"given",
"selectors",
"."
] | 89f6948e24578fed2a90a87871b2263729f90ac3 | https://github.com/kubernetes-retired/contrib/blob/89f6948e24578fed2a90a87871b2263729f90ac3/service-loadbalancer/Godeps/_workspace/src/k8s.io/kubernetes/pkg/client/unversioned/podsecuritypolicy.go#L85-L91 | train |
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.