| 1 | // Copyright 2023 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | //go:build ignore |
| 6 | |
| 7 | // The pprof command prints the total time in a pprof profile provided |
| 8 | // through the standard input. |
| 9 | package main |
| 10 | |
| 11 | import ( |
| 12 | "compress/gzip" |
| 13 | "fmt" |
| 14 | "io" |
| 15 | "log" |
| 16 | "os" |
| 17 | |
| 18 | "golang.org/x/tools/internal/pprof" |
| 19 | ) |
| 20 | |
| 21 | func main() { |
| 22 | rd, err := gzip.NewReader(os.Stdin) |
| 23 | if err != nil { |
| 24 | log.Fatal(err) |
| 25 | } |
| 26 | payload, err := io.ReadAll(rd) |
| 27 | if err != nil { |
| 28 | log.Fatal(err) |
| 29 | } |
| 30 | total, err := pprof.TotalTime(payload) |
| 31 | if err != nil { |
| 32 | log.Fatal(err) |
| 33 | } |
| 34 | fmt.Println(total) |
| 35 | } |