cmd/compilebench: add -pkg flag to compile a single package
Sometimes, as with CL 41493, or when investigating
a reported issue, there's a package of interest
that is not part of the standard compilebench suite.
Add a -pkg flag to allow easy access to the compilebench
set of goodies (allocs, object file stats) without
having to edit and reinstall compilebench itself,
which is what I have been doing.
Change-Id: Id6ca6356cae062208f8686c0cb597ed45fc861c0
Reviewed-on: https://go-review.googlesource.com/41627
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/cmd/compilebench/main.go b/cmd/compilebench/main.go
index 6869db5..e04bd61 100644
--- a/cmd/compilebench/main.go
+++ b/cmd/compilebench/main.go
@@ -37,6 +37,9 @@
// -obj
// Report object file statistics.
//
+// -pkg
+// Benchmark compiling a single package.
+//
// -run regexp
// Only run benchmarks with names matching regexp.
//
@@ -96,6 +99,7 @@
flagCpuprofile = flag.String("cpuprofile", "", "write CPU profile to `file`")
flagMemprofile = flag.String("memprofile", "", "write memory profile to `file`")
flagMemprofilerate = flag.Int64("memprofilerate", -1, "set memory profile `rate`")
+ flagPackage = flag.String("pkg", "", "if set, benchmark the package at path `pkg`")
flagShort = flag.Bool("short", false, "skip long-running benchmarks")
)
@@ -158,6 +162,10 @@
}
for i := 0; i < *flagCount; i++ {
+ if *flagPackage != "" {
+ runBuild("BenchmarkPkg", *flagPackage, i)
+ continue
+ }
for _, tt := range tests {
if tt.long && *flagShort {
continue