ProfileLabels returns printable labels for a profile.
(rpt *Report)
| 1156 | |
| 1157 | // ProfileLabels returns printable labels for a profile. |
| 1158 | func 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 | |
| 1198 | func graphTotal(g *graph.Graph) int64 { |
| 1199 | var total int64 |
searching dependent graphs…