diff options
author | Zach Koopmans <zkoopmans@google.com> | 2021-02-19 17:10:27 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-02-19 17:12:42 -0800 |
commit | 7544eeb242d0aba2da054a1663e043feaedb9618 (patch) | |
tree | f5babceeed52f0e8771c269c35972d7a648ef398 /test/benchmarks/fs | |
parent | 5e22ab93e6b44c036a6ec56858df0874729c4baa (diff) |
Correctly set and respect b.N in fio benchmark.
fio should scale by written/read bytes and not iterate runs
of the fio container.
PiperOrigin-RevId: 358511771
Diffstat (limited to 'test/benchmarks/fs')
-rw-r--r-- | test/benchmarks/fs/fio_test.go | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/test/benchmarks/fs/fio_test.go b/test/benchmarks/fs/fio_test.go index 242374e2c..cc2d1cbbc 100644 --- a/test/benchmarks/fs/fio_test.go +++ b/test/benchmarks/fs/fio_test.go @@ -34,37 +34,31 @@ func BenchmarkFio(b *testing.B) { testCases := []tools.Fio{ { Test: "write", - Size: b.N, BlockSize: 4, IODepth: 4, }, { Test: "write", - Size: b.N, BlockSize: 1024, IODepth: 4, }, { Test: "read", - Size: b.N, BlockSize: 4, IODepth: 4, }, { Test: "read", - Size: b.N, BlockSize: 1024, IODepth: 4, }, { Test: "randwrite", - Size: b.N, BlockSize: 4, IODepth: 4, }, { Test: "randread", - Size: b.N, BlockSize: 4, IODepth: 4, }, @@ -95,6 +89,8 @@ func BenchmarkFio(b *testing.B) { b.Fatalf("Failed to parser paramters: %v", err) } b.Run(name, func(b *testing.B) { + b.StopTimer() + tc.Size = b.N ctx := context.Background() container := machine.GetContainer(ctx, b) defer container.CleanUp(ctx) @@ -141,24 +137,18 @@ func BenchmarkFio(b *testing.B) { } cmd := tc.MakeCmd(outfile) - b.ResetTimer() - b.StopTimer() - - for i := 0; i < b.N; i++ { - if err := harness.DropCaches(machine); err != nil { - b.Fatalf("failed to drop caches: %v", err) - } + if err := harness.DropCaches(machine); err != nil { + b.Fatalf("failed to drop caches: %v", err) + } - // Run fio. - b.StartTimer() - data, err := container.Exec(ctx, dockerutil.ExecOpts{}, cmd...) - if err != nil { - b.Fatalf("failed to run cmd %v: %v", cmd, err) - } - b.StopTimer() - b.SetBytes(1024 * 1024) // Bytes for go reporting (Size is in megabytes). - tc.Report(b, data) + // Run fio. + b.StartTimer() + data, err := container.Exec(ctx, dockerutil.ExecOpts{}, cmd...) + if err != nil { + b.Fatalf("failed to run cmd %v: %v", cmd, err) } + b.StopTimer() + tc.Report(b, data) }) } } |