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

Function ProfileLabels

internal/report/report.go:1158–1196  ·  view source on GitHub ↗

ProfileLabels returns printable labels for a profile.

(rpt *Report)

Source from the content-addressed store, hash-verified

1156
1157// ProfileLabels returns printable labels for a profile.
1158func ProfileLabels(rpt *Report) []string {
1159 label := []string{}
1160 prof := rpt.prof
1161 o := rpt.options
1162 if len(prof.Mapping) > 0 {
1163 if prof.Mapping[0].File != "" {
1164 label = append(label, "File: "+filepath.Base(prof.Mapping[0].File))
1165 }
1166 if prof.Mapping[0].BuildID != "" {
1167 label = append(label, "Build ID: "+prof.Mapping[0].BuildID)
1168 }
1169 }
1170 // Only include comments that do not start with '#'.
1171 for _, c := range prof.Comments {
1172 if !strings.HasPrefix(c, "#") {
1173 label = append(label, c)
1174 }
1175 }
1176 if o.SampleType != "" {
1177 label = append(label, "Type: "+o.SampleType)
1178 }
1179 if url := prof.DocURL; url != "" {
1180 label = append(label, "Doc: "+url)
1181 }
1182 if prof.TimeNanos != 0 {
1183 const layout = "2006-01-02 15:04:05 MST"
1184 label = append(label, "Time: "+time.Unix(0, prof.TimeNanos).Format(layout))
1185 }
1186 if prof.DurationNanos != 0 {
1187 duration := measurement.Label(prof.DurationNanos, "nanoseconds")
1188 totalNanos, totalUnit := measurement.Scale(rpt.total, o.SampleUnit, "nanoseconds")
1189 var ratio string
1190 if totalUnit == "ns" && totalNanos != 0 {
1191 ratio = "(" + measurement.Percentage(int64(totalNanos), prof.DurationNanos) + ")"
1192 }
1193 label = append(label, fmt.Sprintf("Duration: %s, Total samples = %s %s", duration, rpt.formatValue(rpt.total), ratio))
1194 }
1195 return label
1196}
1197
1198func graphTotal(g *graph.Graph) int64 {
1199 var total int64

Callers 9

disasmMethod · 0.92
sourceMethod · 0.92
peekMethod · 0.92
printWebListFunction · 0.92
greetingsFunction · 0.92
TestDocURLInLabelsFunction · 0.85
TestProfileLabelsFunction · 0.85
printTracesFunction · 0.85
reportLabelsFunction · 0.85

Calls 3

LabelFunction · 0.92
ScaleFunction · 0.92
PercentageFunction · 0.92

Tested by 2

TestDocURLInLabelsFunction · 0.68
TestProfileLabelsFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…