diff --git a/examples/limitcpu_test.go b/examples/limitcpu_test.go index 126e15a..6283571 100644 --- a/examples/limitcpu_test.go +++ b/examples/limitcpu_test.go @@ -26,7 +26,7 @@ func ComplexFilterExample(testInputFile, testOverlayFile, testOutputFile string) // 1386105 root 20 0 2114152 273780 31672 R 50.2 1.7 0:16.79 ffmpeg func TestLimitCpu(t *testing.T) { e := ComplexFilterExample("./sample_data/in1.mp4", "./sample_data/overlay.png", "./sample_data/out2.mp4") - err := e.WithCpuCoreRequest(0.1).WithCpuCoreLimit(0.5).RunLinux() + err := e.RunWithResource(0.1, 0.5) if err != nil { assert.Nil(t, err) } diff --git a/run_linux.go b/run_linux.go index 57ba7a7..afe8213 100644 --- a/run_linux.go +++ b/run_linux.go @@ -68,6 +68,10 @@ func writeCGroupFile(rootPath, file string, value string) error { return ioutil.WriteFile(filepath.Join(rootPath, file), []byte(value), 0755) } +func (s *Stream) RunWithResource(cpuRequest, cpuLimit float32) error { + return s.WithCpuCoreRequest(cpuRequest).WithCpuCoreLimit(cpuLimit).RunLinux() +} + func (s *Stream) RunLinux() error { a := s.Context.Value(cgroupConfigKey).(*cgroupConfig) if a.cpuRequest > a.cpuLimit {