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

Function BenchmarkTestPids

cgroup1/pids_test.go:191–237  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

189}
190
191func BenchmarkTestPids(b *testing.B) {
192
193 mock, err := newMock(b)
194 if err != nil {
195 b.Fatal(err)
196 }
197 defer func() {
198 if err := mock.delete(); err != nil {
199 b.Errorf("failed delete: %v", err)
200 }
201 }()
202
203 pids := NewPids(mock.root)
204 if pids == nil {
205 b.Fatal("pids is nil")
206 }
207 pidsLimit := int64(10)
208 resources := specs.LinuxResources{
209 Pids: &specs.LinuxPids{
210 Limit: &pidsLimit,
211 },
212 }
213
214 err = pids.Create("test", &resources)
215 if err != nil {
216 b.Fatal(err)
217 }
218
219 current := filepath.Join(mock.root, "pids", "test", "pids.current")
220 if err = os.WriteFile(
221 current,
222 []byte(strconv.Itoa(5)),
223 defaultFilePerm,
224 ); err != nil {
225 b.Fatal(err)
226 }
227
228 b.ReportAllocs()
229
230 for i := 0; i < b.N; i++ {
231 metrics := v1.Metrics{}
232 err = pids.Stat("test", &metrics)
233 if err != nil {
234 b.Fatal(err)
235 }
236 }
237}

Callers

nothing calls this directly

Calls 5

newMockFunction · 0.85
NewPidsFunction · 0.85
deleteMethod · 0.80
CreateMethod · 0.65
StatMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…