MCPcopy Create free account
hub / github.com/containerd/cgroups / BenchmarkStatFiltered

Function BenchmarkStatFiltered

cgroup2/manager_test.go:563–604  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

561}
562
563func BenchmarkStatFiltered(b *testing.B) {
564 checkCgroupMode(b)
565 group := "/stat-filtered-bench-cg"
566 groupPath := fmt.Sprintf("%s-%d", group, os.Getpid())
567 c, err := NewManager(defaultCgroup2Path, groupPath, &Resources{})
568 require.NoErrorf(b, err, "failed to init new cgroup manager")
569 b.Cleanup(func() {
570 _ = c.Delete()
571 })
572
573 b.Run("StatAll", func(b *testing.B) {
574 b.ReportAllocs()
575 for i := 0; i < b.N; i++ {
576 _, err := c.StatFiltered(StatAll)
577 require.NoError(b, err)
578 }
579 })
580
581 b.Run("CPUOnly", func(b *testing.B) {
582 b.ReportAllocs()
583 for i := 0; i < b.N; i++ {
584 _, err := c.StatFiltered(StatCPU)
585 require.NoError(b, err)
586 }
587 })
588
589 b.Run("MemoryOnly", func(b *testing.B) {
590 b.ReportAllocs()
591 for i := 0; i < b.N; i++ {
592 _, err := c.StatFiltered(StatMemory)
593 require.NoError(b, err)
594 }
595 })
596
597 b.Run("CPUAndMemory", func(b *testing.B) {
598 b.ReportAllocs()
599 for i := 0; i < b.N; i++ {
600 _, err := c.StatFiltered(StatCPU | StatMemory)
601 require.NoError(b, err)
602 }
603 })
604}
605
606func toPtr[T any](v T) *T {
607 return &v

Callers

nothing calls this directly

Calls 4

DeleteMethod · 0.95
StatFilteredMethod · 0.95
checkCgroupModeFunction · 0.85
NewManagerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…