diff options
author | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-08-22 17:43:43 -0300 |
---|---|---|
committer | Giuliano Belinassi <giuliano.belinassi@usp.br> | 2020-08-22 17:43:43 -0300 |
commit | a926878ddbd5a98b272c22171ce58663fc04c3e0 (patch) | |
tree | 86af256e5d9a9c06263c00adc90e5fe348008c43 /libgo/go/runtime/pprof/label.go | |
parent | 542730f087133690b47e036dfd43eb0db8a650ce (diff) | |
parent | 07cbaed8ba7d1b6e4ab3a9f44175502a4e1ecdb1 (diff) | |
download | gcc-devel/autopar_devel.zip gcc-devel/autopar_devel.tar.gz gcc-devel/autopar_devel.tar.bz2 |
Merge branch 'autopar_rebase2' into autopar_develdevel/autopar_devel
Quickly commit changes in the rebase branch.
Diffstat (limited to 'libgo/go/runtime/pprof/label.go')
-rw-r--r-- | libgo/go/runtime/pprof/label.go | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/libgo/go/runtime/pprof/label.go b/libgo/go/runtime/pprof/label.go index 2d92ef7..b614f12 100644 --- a/libgo/go/runtime/pprof/label.go +++ b/libgo/go/runtime/pprof/label.go @@ -6,6 +6,9 @@ package pprof import ( "context" + "fmt" + "sort" + "strings" ) type label struct { @@ -34,6 +37,23 @@ func labelValue(ctx context.Context) labelMap { // that admits incremental immutable modification more efficiently. type labelMap map[string]string +// String statisfies Stringer and returns key, value pairs in a consistent +// order. +func (l *labelMap) String() string { + if l == nil { + return "" + } + keyVals := make([]string, 0, len(*l)) + + for k, v := range *l { + keyVals = append(keyVals, fmt.Sprintf("%q:%q", k, v)) + } + + sort.Strings(keyVals) + + return "{" + strings.Join(keyVals, ", ") + "}" +} + // WithLabels returns a new context.Context with the given labels added. // A label overwrites a prior label with the same key. func WithLabels(ctx context.Context, labels LabelSet) context.Context { @@ -54,7 +74,8 @@ func WithLabels(ctx context.Context, labels LabelSet) context.Context { // Labels takes an even number of strings representing key-value pairs // and makes a LabelSet containing them. // A label overwrites a prior label with the same key. -// Currently only CPU profile utilizes labels information. +// Currently only the CPU and goroutine profiles utilize any labels +// information. // See https://golang.org/issue/23458 for details. func Labels(args ...string) LabelSet { if len(args)%2 != 0 { |