Unreviewed changes
2 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: cmd/resultdbpprof/main.go
Insertions: 26, Deletions: 4.
@@ -42,14 +42,13 @@
"time"
"github.com/google/pprof/profile"
- "golang.org/x/sync/errgroup"
- "google.golang.org/protobuf/types/known/fieldmaskpb"
-
"go.chromium.org/luci/auth"
bbpb "go.chromium.org/luci/buildbucket/proto"
"go.chromium.org/luci/grpc/prpc"
"go.chromium.org/luci/hardcoded/chromeinfra"
rdbpb "go.chromium.org/luci/resultdb/proto/v1"
+ "golang.org/x/sync/errgroup"
+ "google.golang.org/protobuf/types/known/fieldmaskpb"
)
var (
@@ -57,6 +56,24 @@
public = flag.Bool("public", true, "whether the build is public or not")
)
+func init() {
+ flag.Usage = func() {
+ fmt.Fprintf(flag.CommandLine.Output(), "Usage: %s [flags] <build ID>\n", os.Args[0])
+ fmt.Fprintf(flag.CommandLine.Output(), "\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "Downloads test results for a LUCI build and generates a pprof\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "profile of their execution times. Useful for understanding test\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "execution times and identifying low hanging fruit to speed up CI.\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "Results are written to '<build ID>.prof' in the current working\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "directory.\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "This tool expects Go test names of the form 'pkg.TestX/Y/Z'.\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "Test names not matching this pattern may appear in the output in\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "an unexpected form.\n")
+ fmt.Fprintf(flag.CommandLine.Output(), "\n")
+ flag.PrintDefaults()
+ }
+}
+
func main() {
// Validate flags.
flag.Parse()
@@ -67,7 +84,12 @@
flag.Usage()
os.Exit(1)
}
- buildID, err := strconv.ParseInt(flag.Arg(0), 10, 64)
+ idArg := flag.Arg(0)
+ idArg, _ = strings.CutPrefix(idArg, "b") // Allow optional 'b' prefix for easier copy-pasting.
+ buildID, err := strconv.ParseInt(idArg, 10, 64)
+ if err != nil {
+ log.Fatalf("parsing build ID %s: %v", flag.Arg(0), err)
+ }
// Create client.
ctx := context.Background()
```
Change information
Commit message:
cmd/resultdbpprof: add tool to get a test execution profile
Change-Id: Ia5e0a9265fab5b0f8ee3c5aca00c43df18cac6fe
Files:
- A cmd/resultdbpprof/main.go
- M go.mod
- M go.sum
Change size: L
Delta: 3 files changed, 310 insertions(+), 1 deletion(-)
Branch: refs/heads/master
Submit Requirements:
Code-Review: +1 by Dmitri Shuralyov, +2 by Dmitri Shuralyov
TryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI