github.com/jgbaldwinbrown/perf@v0.1.1/benchproc/nonsingular.go (about) 1 // Copyright 2022 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package benchproc 6 7 // NonSingularFields returns the subset of Fields for which at least two of keys 8 // have different values. 9 // 10 // This is useful for warning the user if aggregating a set of results has 11 // resulted in potentially hiding important configuration differences. Typically 12 // these keys are "residue" keys produced by ProjectionParser.Residue. 13 func NonSingularFields(keys []Key) []*Field { 14 // TODO: This is generally used on residue keys, but those might 15 // just have ".fullname" (generally with implicit exclusions). 16 // Telling the user that a set of benchmarks varies in ".fullname" 17 // isn't nearly as useful as listing out the specific subfields. We 18 // should synthesize "/N" subfields for ".fullname" for this (this 19 // makes even more sense if we make .fullname a group field that 20 // already has these subfields). 21 22 if len(keys) <= 1 { 23 // There can't be any differences. 24 return nil 25 } 26 var out []*Field 27 fields := commonProjection(keys).FlattenedFields() 28 for _, f := range fields { 29 base := keys[0].Get(f) 30 for _, k := range keys[1:] { 31 if k.Get(f) != base { 32 out = append(out, f) 33 break 34 } 35 } 36 } 37 return out 38 }