|
@@ -25,6 +25,7 @@ import (
|
25
|
25
|
"sort"
|
26
|
26
|
"strconv"
|
27
|
27
|
"strings"
|
|
28
|
+ "text/tabwriter"
|
28
|
29
|
"time"
|
29
|
30
|
|
30
|
31
|
"github.com/google/pprof/internal/graph"
|
|
@@ -620,25 +621,23 @@ func printTags(w io.Writer, rpt *Report) error {
|
620
|
621
|
for _, s := range p.Sample {
|
621
|
622
|
for key, vals := range s.Label {
|
622
|
623
|
for _, val := range vals {
|
623
|
|
- if valueMap, ok := tagMap[key]; ok {
|
624
|
|
- valueMap[val] = valueMap[val] + s.Value[0]
|
625
|
|
- continue
|
|
624
|
+ valueMap, ok := tagMap[key]
|
|
625
|
+ if !ok {
|
|
626
|
+ valueMap = make(map[string]int64)
|
|
627
|
+ tagMap[key] = valueMap
|
626
|
628
|
}
|
627
|
|
- valueMap := make(map[string]int64)
|
628
|
|
- valueMap[val] = s.Value[0]
|
629
|
|
- tagMap[key] = valueMap
|
|
629
|
+ valueMap[val] += o.SampleValue(s.Value)
|
630
|
630
|
}
|
631
|
631
|
}
|
632
|
632
|
for key, vals := range s.NumLabel {
|
633
|
633
|
for _, nval := range vals {
|
634
|
634
|
val := formatTag(nval, key)
|
635
|
|
- if valueMap, ok := tagMap[key]; ok {
|
636
|
|
- valueMap[val] = valueMap[val] + s.Value[0]
|
637
|
|
- continue
|
|
635
|
+ valueMap, ok := tagMap[key]
|
|
636
|
+ if !ok {
|
|
637
|
+ valueMap = make(map[string]int64)
|
|
638
|
+ tagMap[key] = valueMap
|
638
|
639
|
}
|
639
|
|
- valueMap := make(map[string]int64)
|
640
|
|
- valueMap[val] = s.Value[0]
|
641
|
|
- tagMap[key] = valueMap
|
|
640
|
+ valueMap[val] += o.SampleValue(s.Value)
|
642
|
641
|
}
|
643
|
642
|
}
|
644
|
643
|
}
|
|
@@ -647,6 +646,7 @@ func printTags(w io.Writer, rpt *Report) error {
|
647
|
646
|
for key := range tagMap {
|
648
|
647
|
tagKeys = append(tagKeys, &graph.Tag{Name: key})
|
649
|
648
|
}
|
|
649
|
+ tabw := tabwriter.NewWriter(w, 0, 0, 1, ' ', tabwriter.AlignRight)
|
650
|
650
|
for _, tagKey := range graph.SortTags(tagKeys, true) {
|
651
|
651
|
var total int64
|
652
|
652
|
key := tagKey.Name
|
|
@@ -656,18 +656,19 @@ func printTags(w io.Writer, rpt *Report) error {
|
656
|
656
|
tags = append(tags, &graph.Tag{Name: t, Flat: c})
|
657
|
657
|
}
|
658
|
658
|
|
659
|
|
- fmt.Fprintf(w, "%s: Total %d\n", key, total)
|
|
659
|
+ f, u := measurement.Scale(total, o.SampleUnit, o.OutputUnit)
|
|
660
|
+ fmt.Fprintf(tabw, "%s:\t Total %.1f%s\n", key, f, u)
|
660
|
661
|
for _, t := range graph.SortTags(tags, true) {
|
|
662
|
+ f, u := measurement.Scale(t.FlatValue(), o.SampleUnit, o.OutputUnit)
|
661
|
663
|
if total > 0 {
|
662
|
|
- fmt.Fprintf(w, " %8d (%s): %s\n", t.FlatValue(),
|
663
|
|
- percentage(t.FlatValue(), total), t.Name)
|
|
664
|
+ fmt.Fprintf(tabw, " \t%.1f%s (%s):\t %s\n", f, u, percentage(t.FlatValue(), total), t.Name)
|
664
|
665
|
} else {
|
665
|
|
- fmt.Fprintf(w, " %8d: %s\n", t.FlatValue(), t.Name)
|
|
666
|
+ fmt.Fprintf(tabw, " \t%.1f%s:\t %s\n", f, u, t.Name)
|
666
|
667
|
}
|
667
|
668
|
}
|
668
|
|
- fmt.Fprintln(w)
|
|
669
|
+ fmt.Fprintln(tabw)
|
669
|
670
|
}
|
670
|
|
- return nil
|
|
671
|
+ return tabw.Flush()
|
671
|
672
|
}
|
672
|
673
|
|
673
|
674
|
// printComments prints all freeform comments in the profile.
|