summaryrefslogtreecommitdiffhomepage
path: root/test/benchmarks/harness
diff options
context:
space:
mode:
authorZach Koopmans <zkoopmans@google.com>2020-11-10 21:18:57 -0800
committergVisor bot <gvisor-bot@google.com>2020-11-10 21:20:52 -0800
commit792cbc06de41f226f76f55a828dfcfad9b8fb16e (patch)
tree64b37ecff27afb83ad0b0533085308ea0c3239bb /test/benchmarks/harness
parent7f2183df9c529790cd99d31a185ae4ddd5f355c6 (diff)
Add debug logs to startup benchmark.
PiperOrigin-RevId: 341757694
Diffstat (limited to 'test/benchmarks/harness')
-rw-r--r--test/benchmarks/harness/harness.go3
-rw-r--r--test/benchmarks/harness/util.go9
2 files changed, 11 insertions, 1 deletions
diff --git a/test/benchmarks/harness/harness.go b/test/benchmarks/harness/harness.go
index e14cce987..5c9d0e01e 100644
--- a/test/benchmarks/harness/harness.go
+++ b/test/benchmarks/harness/harness.go
@@ -24,7 +24,8 @@ import (
)
var (
- help = flag.Bool("help", false, "print this usage message")
+ help = flag.Bool("help", false, "print this usage message")
+ debug = flag.Bool("debug", false, "turns on debug messages for individual benchmarks")
)
// Harness is a handle for managing state in benchmark runs.
diff --git a/test/benchmarks/harness/util.go b/test/benchmarks/harness/util.go
index 86b863f78..aeac7ebff 100644
--- a/test/benchmarks/harness/util.go
+++ b/test/benchmarks/harness/util.go
@@ -18,6 +18,7 @@ import (
"context"
"fmt"
"net"
+ "testing"
"gvisor.dev/gvisor/pkg/test/dockerutil"
"gvisor.dev/gvisor/pkg/test/testutil"
@@ -46,3 +47,11 @@ func DropCaches(machine Machine) error {
}
return nil
}
+
+// DebugLog prints debug messages if the debug flag is set.
+func DebugLog(b *testing.B, msg string, args ...interface{}) {
+ b.Helper()
+ if *debug {
+ b.Logf(msg, args...)
+ }
+}