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

Function TestTagCollapse

internal/graph/dotgraph_test.go:304–352  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

302}
303
304func TestTagCollapse(t *testing.T) {
305
306 makeTag := func(name, unit string, value, flat, cum int64) *Tag {
307 return &Tag{name, unit, value, flat, 0, cum, 0}
308 }
309
310 tagSource := []*Tag{
311 makeTag("12mb", "mb", 12, 100, 100),
312 makeTag("1kb", "kb", 1, 1, 1),
313 makeTag("1mb", "mb", 1, 1000, 1000),
314 makeTag("2048mb", "mb", 2048, 1000, 1000),
315 makeTag("1b", "b", 1, 100, 100),
316 makeTag("2b", "b", 2, 100, 100),
317 makeTag("7b", "b", 7, 100, 100),
318 }
319
320 tagWant := [][]*Tag{
321 {
322 makeTag("1B..2GB", "", 0, 2401, 2401),
323 },
324 {
325 makeTag("2GB", "", 0, 1000, 1000),
326 makeTag("1B..12MB", "", 0, 1401, 1401),
327 },
328 {
329 makeTag("2GB", "", 0, 1000, 1000),
330 makeTag("12MB", "", 0, 100, 100),
331 makeTag("1B..1MB", "", 0, 1301, 1301),
332 },
333 {
334 makeTag("2GB", "", 0, 1000, 1000),
335 makeTag("1MB", "", 0, 1000, 1000),
336 makeTag("2B..1kB", "", 0, 201, 201),
337 makeTag("1B", "", 0, 100, 100),
338 makeTag("12MB", "", 0, 100, 100),
339 },
340 }
341
342 for _, tc := range tagWant {
343 var got, want []*Tag
344 b := builder{nil, &DotAttributes{}, &DotConfig{}}
345 got = b.collapsedTags(tagSource, len(tc), true)
346 want = SortTags(tc, true)
347
348 if !reflect.DeepEqual(got, want) {
349 t.Errorf("collapse to %d, got:\n%v\nwant:\n%v", len(tc), tagString(got), tagString(want))
350 }
351 }
352}
353
354func TestEscapeForDot(t *testing.T) {
355 for _, tc := range []struct {

Callers

nothing calls this directly

Calls 3

collapsedTagsMethod · 0.95
SortTagsFunction · 0.85
tagStringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…