Skip to content

Commit 7f0ad5b

Browse files
tatianabTatiana Bradley
authored andcommitted
cmd/vulnreport: add cpuprofile option to vulnreport
This will allow us to identify bottlenecks in the vulnreport command. Change-Id: I4e9a3376dba2d7fd807ef812622eed0812596fb5 Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/459641 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Julie Qiu <[email protected]> Reviewed-by: Tatiana Bradley <[email protected]> Run-TryBot: Tatiana Bradley <[email protected]>
1 parent db887e7 commit 7f0ad5b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cmd/vulnreport/main.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"path/filepath"
2020
"regexp"
2121
"runtime"
22+
"runtime/pprof"
2223
"sort"
2324
"strconv"
2425
"strings"
@@ -49,6 +50,7 @@ var (
4950
updateIssue = flag.Bool("up", false, "for commit, create a CL that updates (doesn't fix) the tracking bug")
5051
indent = flag.Bool("indent", false, "for newcve, indent JSON output")
5152
closedOk = flag.Bool("closed-ok", false, "for create & create-excluded, allow closed issues to be created")
53+
cpuprofile = flag.String("cpuprofile", "", "write cpuprofile to file")
5254
)
5355

5456
func main() {
@@ -90,6 +92,16 @@ func main() {
9092
args = flag.Args()[1:]
9193
}
9294

95+
// Start CPU profiler.
96+
if *cpuprofile != "" {
97+
f, err := os.Create(*cpuprofile)
98+
if err != nil {
99+
log.Fatal(err)
100+
}
101+
pprof.StartCPUProfile(f)
102+
defer pprof.StopCPUProfile()
103+
}
104+
93105
// setupCreate clones the CVEList repo and can be very slow,
94106
// so commands that require this functionality are separated from other
95107
// commands.

0 commit comments

Comments
 (0)