File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ package integration
2+
3+ import (
4+ "os"
5+ "testing"
6+
7+ "github.com/opencontainers/runc/libcontainer"
8+ )
9+
10+ func BenchmarkExecTrue (b * testing.B ) {
11+ config := newTemplateConfig (b , nil )
12+ container , err := newContainer (b , config )
13+ ok (b , err )
14+ defer destroyContainer (container )
15+
16+ // Execute a first process in the container
17+ stdinR , stdinW , err := os .Pipe ()
18+ ok (b , err )
19+ process := & libcontainer.Process {
20+ Cwd : "/" ,
21+ Args : []string {"cat" },
22+ Env : standardEnvironment ,
23+ Stdin : stdinR ,
24+ Init : true ,
25+ }
26+ err = container .Run (process )
27+ _ = stdinR .Close ()
28+ defer func () {
29+ _ = stdinW .Close ()
30+ if _ , err := process .Wait (); err != nil {
31+ b .Log (err )
32+ }
33+ }()
34+ ok (b , err )
35+
36+ b .ResetTimer ()
37+ for i := 0 ; i < b .N ; i ++ {
38+ exec := & libcontainer.Process {
39+ Cwd : "/" ,
40+ Args : []string {"/bin/true" },
41+ Env : standardEnvironment ,
42+ LogLevel : "0" , // Minimize forwardChildLogs involvement.
43+ }
44+ err := container .Run (exec )
45+ if err != nil {
46+ b .Fatal ("exec failed:" , err )
47+ }
48+ waitProcess (exec , b )
49+ }
50+ b .StopTimer ()
51+ }
You can’t perform that action at this time.
0 commit comments