Fix bug with iperf and don't profile runc.

Fix issue with iperf where b.N wasn't changing across runs.
Also, if the given runtime is runc/not given, don't run a profile against it.

PiperOrigin-RevId: 357231450
This commit is contained in:
Zach Koopmans 2021-02-12 11:25:53 -08:00 committed by gVisor bot
parent a6d813ad55
commit ba51999fa6
2 changed files with 6 additions and 5 deletions

View File

@ -216,7 +216,7 @@ func (c *Container) Create(ctx context.Context, r RunOpts, args ...string) error
} }
func (c *Container) create(ctx context.Context, profileImage string, conf *container.Config, hostconf *container.HostConfig, netconf *network.NetworkingConfig) error { func (c *Container) create(ctx context.Context, profileImage string, conf *container.Config, hostconf *container.HostConfig, netconf *network.NetworkingConfig) error {
if c.runtime != "" { if c.runtime != "" && c.runtime != "runc" {
// Use the image name as provided here; which normally represents the // Use the image name as provided here; which normally represents the
// unmodified "basic/alpine" image name. This should be easy to grok. // unmodified "basic/alpine" image name. This should be easy to grok.
c.profileInit(profileImage) c.profileInit(profileImage)

View File

@ -25,10 +25,6 @@ import (
) )
func BenchmarkIperf(b *testing.B) { func BenchmarkIperf(b *testing.B) {
iperf := tools.Iperf{
Num: b.N,
}
clientMachine, err := harness.GetMachine() clientMachine, err := harness.GetMachine()
if err != nil { if err != nil {
b.Fatalf("failed to get machine: %v", err) b.Fatalf("failed to get machine: %v", err)
@ -93,6 +89,10 @@ func BenchmarkIperf(b *testing.B) {
b.Fatalf("failed to wait for server: %v", err) b.Fatalf("failed to wait for server: %v", err)
} }
iperf := tools.Iperf{
Num: b.N,
}
// Run the client. // Run the client.
b.ResetTimer() b.ResetTimer()
out, err := client.Run(ctx, dockerutil.RunOpts{ out, err := client.Run(ctx, dockerutil.RunOpts{
@ -103,6 +103,7 @@ func BenchmarkIperf(b *testing.B) {
} }
b.StopTimer() b.StopTimer()
iperf.Report(b, out) iperf.Report(b, out)
b.StartTimer()
}) })
} }
} }