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

Function TestIdentifyNumLabelUnits

internal/driver/driver_test.go:1159–1289  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1157}
1158
1159func TestIdentifyNumLabelUnits(t *testing.T) {
1160 var tagFilterTests = []struct {
1161 desc string
1162 tagVals []map[string][]int64
1163 tagUnits []map[string][]string
1164 wantUnits map[string]string
1165 allowedRx string
1166 wantIgnoreErrCount int
1167 }{
1168 {
1169 "Multiple keys, no units for all keys",
1170 []map[string][]int64{{"keyA": {131072}, "keyB": {128}}},
1171 []map[string][]string{{"keyA": {}, "keyB": {""}}},
1172 map[string]string{"keyA": "keyA", "keyB": "keyB"},
1173 "",
1174 0,
1175 },
1176 {
1177 "Multiple keys, different units for each key",
1178 []map[string][]int64{{"keyA": {131072}, "keyB": {128}}},
1179 []map[string][]string{{"keyA": {"bytes"}, "keyB": {"kilobytes"}}},
1180 map[string]string{"keyA": "bytes", "keyB": "kilobytes"},
1181 "",
1182 0,
1183 },
1184 {
1185 "Multiple keys with multiple values, different units for each key",
1186 []map[string][]int64{{"keyC": {131072, 1}, "keyD": {128, 252}}},
1187 []map[string][]string{{"keyC": {"bytes", "bytes"}, "keyD": {"kilobytes", "kilobytes"}}},
1188 map[string]string{"keyC": "bytes", "keyD": "kilobytes"},
1189 "",
1190 0,
1191 },
1192 {
1193 "Multiple keys with multiple values, some units missing",
1194 []map[string][]int64{{"key1": {131072, 1}, "A": {128, 252}, "key3": {128}, "key4": {1}}, {"key3": {128}, "key4": {1}}},
1195 []map[string][]string{{"key1": {"", "bytes"}, "A": {"kilobytes", ""}, "key3": {""}, "key4": {"hour"}}, {"key3": {"seconds"}, "key4": {""}}},
1196 map[string]string{"key1": "bytes", "A": "kilobytes", "key3": "seconds", "key4": "hour"},
1197 "",
1198 0,
1199 },
1200 {
1201 "One key with three units in same sample",
1202 []map[string][]int64{{"key": {8, 8, 16}}},
1203 []map[string][]string{{"key": {"bytes", "megabytes", "kilobytes"}}},
1204 map[string]string{"key": "bytes"},
1205 `(For tag key used unit bytes, also encountered unit\(s\) kilobytes, megabytes)`,
1206 1,
1207 },
1208 {
1209 "One key with four units in same sample",
1210 []map[string][]int64{{"key": {8, 8, 16, 32}}},
1211 []map[string][]string{{"key": {"bytes", "kilobytes", "a", "megabytes"}}},
1212 map[string]string{"key": "bytes"},
1213 `(For tag key used unit bytes, also encountered unit\(s\) a, kilobytes, megabytes)`,
1214 1,
1215 },
1216 {

Callers

nothing calls this directly

Calls 1

identifyNumLabelUnitsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…