package runner import ( "testing" ) func BenchmarkContainerRun(b *testing.B) { srv := GetService(false).(*service) args := &RunArgs{ Program: ProgramArgs{Args: []string{"/bin/sh", "-c", "echo hello world"}}, Runtime: RuntimeArgs{Rootfs: RootfsRunDir, Memory: 16 * 1024 * 1024}, } b.ResetTimer() for i := 0; i < b.N; i++ { _, err := srv.JailRun(args) if err != nil { b.Error(err) } } } func BenchmarkContainerRunPool(b *testing.B) { srv := GetService(false).(*service) args := &RunArgs{ Program: ProgramArgs{Args: []string{"/bin/sh", "-c", "echo hello world"}}, Runtime: RuntimeArgs{Rootfs: RootfsRunDir, Memory: 16 * 1024 * 1024}, } b.ResetTimer() var ids []uint64 for i := 0; i < b.N; i++ { id := srv.JailRunPool(args) ids = append(ids, id) } for _, id := range ids { buf := srv.pool.WaitForTask(id) if buf.Error != nil { b.Error(buf.Error) } } }