mirror of
https://github.com/anchore/syft.git
synced 2026-10-31 14:36:33 +01:00
add profiler dev option
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
+22
-6
@@ -5,14 +5,9 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"runtime/pprof"
|
||||
"strings"
|
||||
|
||||
"github.com/anchore/syft/syft/distro"
|
||||
|
||||
"github.com/anchore/syft/syft/pkg"
|
||||
|
||||
"github.com/anchore/syft/syft/source"
|
||||
|
||||
"github.com/anchore/syft/internal"
|
||||
"github.com/anchore/syft/internal/anchore"
|
||||
"github.com/anchore/syft/internal/bus"
|
||||
@@ -20,8 +15,11 @@ import (
|
||||
"github.com/anchore/syft/internal/ui"
|
||||
"github.com/anchore/syft/internal/version"
|
||||
"github.com/anchore/syft/syft"
|
||||
"github.com/anchore/syft/syft/distro"
|
||||
"github.com/anchore/syft/syft/event"
|
||||
"github.com/anchore/syft/syft/pkg"
|
||||
"github.com/anchore/syft/syft/presenter"
|
||||
"github.com/anchore/syft/syft/source"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/client"
|
||||
@@ -56,7 +54,25 @@ You can also explicitly specify the scheme to use:
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if appConfig.Dev.ProfileCPU {
|
||||
f, err := os.Create("cpu.profile")
|
||||
if err != nil {
|
||||
log.Errorf("unable to create CPU profile: %+v", err)
|
||||
} else {
|
||||
err := pprof.StartCPUProfile(f)
|
||||
if err != nil {
|
||||
log.Errorf("unable to start CPU profile: %+v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err := doRunCmd(cmd, args)
|
||||
|
||||
if appConfig.Dev.ProfileCPU {
|
||||
pprof.StopCPUProfile()
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Errorf(err.Error())
|
||||
os.Exit(1)
|
||||
|
||||
Reference in New Issue
Block a user