@@ -247,3 +247,40 @@ func TestRemoveNetMetrics(t *testing.T) {
247
247
}
248
248
}
249
249
}
250
+
251
+ func BenchmarkGetSpecCgroupV2 (b * testing.B ) {
252
+ root , err := os .Getwd ()
253
+ if err != nil {
254
+ b .Fatalf ("getwd: %s" , err )
255
+ }
256
+
257
+ cgroupPaths := map [string ]string {
258
+ "" : filepath .Join (root , "test_resources/cgroup_v2/test1" ),
259
+ }
260
+
261
+ for i := 0 ; i < b .N ; i ++ {
262
+ _ , err := getSpecInternal (cgroupPaths , & mockInfoProvider {}, false , false , true )
263
+ assert .Nil (b , err )
264
+ }
265
+
266
+ }
267
+
268
+ func BenchmarkGetSpecCgroupV1 (b * testing.B ) {
269
+ root , err := os .Getwd ()
270
+ if err != nil {
271
+ b .Fatalf ("getwd: %s" , err )
272
+ }
273
+
274
+ cgroupPaths := map [string ]string {
275
+ "memory" : filepath .Join (root , "test_resources/cgroup_v1/test1/memory" ),
276
+ "cpu" : filepath .Join (root , "test_resources/cgroup_v1/test1/cpu" ),
277
+ "cpuset" : filepath .Join (root , "test_resources/cgroup_v1/test1/cpuset" ),
278
+ "pids" : filepath .Join (root , "test_resources/cgroup_v1/test1/pids" ),
279
+ }
280
+
281
+ for i := 0 ; i < b .N ; i ++ {
282
+ _ , err := getSpecInternal (cgroupPaths , & mockInfoProvider {}, false , false , false )
283
+ assert .Nil (b , err )
284
+ }
285
+
286
+ }
0 commit comments