summaryrefslogtreecommitdiffhomepage
path: root/test/benchmarks/fs
diff options
context:
space:
mode:
authorZach Koopmans <zkoopmans@google.com>2020-08-31 17:15:14 -0700
committerAndrei Vagin <avagin@gmail.com>2020-09-09 17:53:10 -0700
commit307366b64e7dbc7526213d59bf907f4c65f44a40 (patch)
tree2c4d2e8fa18c1075e074f5e3cda38a7b3af79a70 /test/benchmarks/fs
parentae2e5a38a5e7fb9035d4b1c959a98ef306788d89 (diff)
Fix bug in bazel build benchmark.
PiperOrigin-RevId: 329409802
Diffstat (limited to 'test/benchmarks/fs')
-rw-r--r--test/benchmarks/fs/bazel_test.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/test/benchmarks/fs/bazel_test.go b/test/benchmarks/fs/bazel_test.go
index fdbbfe280..ef1b8e4ea 100644
--- a/test/benchmarks/fs/bazel_test.go
+++ b/test/benchmarks/fs/bazel_test.go
@@ -62,7 +62,7 @@ func runBuildBenchmark(b *testing.B, image, workdir, target string) {
container := machine.GetContainer(ctx, b)
defer container.CleanUp(ctx)
- // Start a container and sleep by an order of b.N.
+ // Start a container and sleep.
if err := container.Spawn(ctx, dockerutil.RunOpts{
Image: image,
}, "sleep", fmt.Sprintf("%d", 1000000)); err != nil {
@@ -70,12 +70,13 @@ func runBuildBenchmark(b *testing.B, image, workdir, target string) {
}
// If we are running on a tmpfs, copy to /tmp which is a tmpfs.
+ prefix := ""
if bm.tmpfs {
if out, err := container.Exec(ctx, dockerutil.ExecOpts{},
"cp", "-r", workdir, "/tmp/."); err != nil {
b.Fatalf("failed to copy directory: %v (%s)", err, out)
}
- workdir = "/tmp" + workdir
+ prefix = "/tmp"
}
// Restart profiles after the copy.
@@ -94,7 +95,7 @@ func runBuildBenchmark(b *testing.B, image, workdir, target string) {
b.StartTimer()
got, err := container.Exec(ctx, dockerutil.ExecOpts{
- WorkDir: workdir,
+ WorkDir: prefix + workdir,
}, "bazel", "build", "-c", "opt", target)
if err != nil {
b.Fatalf("build failed with: %v", err)
@@ -107,7 +108,7 @@ func runBuildBenchmark(b *testing.B, image, workdir, target string) {
}
// Clean bazel in case we use b.N.
_, err = container.Exec(ctx, dockerutil.ExecOpts{
- WorkDir: workdir,
+ WorkDir: prefix + workdir,
}, "bazel", "clean")
if err != nil {
b.Fatalf("build failed with: %v", err)