43 lines
801 B
Go
43 lines
801 B
Go
|
package runner
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func BenchmarkContainerRun(b *testing.B) {
|
||
|
srv := GetService(false).(*service)
|
||
|
|
||
|
args := &RunArgs{
|
||
|
Program: ProgramArgs{Args: []string{"sh", "-c", "echo hello world"}},
|
||
|
Runtime: RuntimeArgs{Image: ContainerImageRun},
|
||
|
}
|
||
|
|
||
|
b.ResetTimer()
|
||
|
for i := 0; i < b.N; i++ {
|
||
|
_, err := srv.ContainerRun(args)
|
||
|
if err != nil {
|
||
|
b.Error(err)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func BenchmarkContainerRunPool(b *testing.B) {
|
||
|
srv := GetService(false).(*service)
|
||
|
|
||
|
args := &RunArgs{
|
||
|
Program: ProgramArgs{Args: []string{"sh", "-c", "echo hello world"}},
|
||
|
Runtime: RuntimeArgs{Image: ContainerImageRun},
|
||
|
}
|
||
|
|
||
|
b.ResetTimer()
|
||
|
var ids []uint64
|
||
|
for i := 0; i < b.N; i++ {
|
||
|
id := srv.ContainerRunPool(args)
|
||
|
ids = append(ids, id)
|
||
|
}
|
||
|
|
||
|
for _, id := range ids {
|
||
|
srv.pool.WaitForTask(id)
|
||
|
}
|
||
|
}
|