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

Function TestEmptyMappingMerge

profile/profile_test.go:963–995  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

961}
962
963func TestEmptyMappingMerge(t *testing.T) {
964 // Aggregate a profile with itself and once again with a factor of
965 // -2. Should end up with an empty profile (all samples for a
966 // location should add up to 0).
967
968 prof1 := testProfile1.Copy()
969 prof2 := testProfile1NoMapping.Copy()
970 p1, err := Merge([]*Profile{prof2, prof1})
971 if err != nil {
972 t.Errorf("merge error: %v", err)
973 }
974 prof2.Scale(-2)
975 prof, err := Merge([]*Profile{p1, prof2})
976 if err != nil {
977 t.Errorf("merge error: %v", err)
978 }
979
980 // Use aggregation to merge locations at function granularity.
981 if err := prof.Aggregate(false, true, false, false, false, false); err != nil {
982 t.Errorf("aggregating after merge: %v", err)
983 }
984
985 samples := make(map[string]int64)
986 for _, s := range prof.Sample {
987 tb := locationHash(s)
988 samples[tb] = samples[tb] + s.Value[0]
989 }
990 for s, v := range samples {
991 if v != 0 {
992 t.Errorf("nonzero value for sample %s: %d", s, v)
993 }
994 }
995}
996
997func TestNormalizeBySameProfile(t *testing.T) {
998 pb := testProfile1.Copy()

Callers

nothing calls this directly

Calls 5

MergeFunction · 0.85
locationHashFunction · 0.85
CopyMethod · 0.80
ScaleMethod · 0.80
AggregateMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…