Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 93f2901

Browse files
committed
move profiling to main method
1 parent d584250 commit 93f2901

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

cmd/analyze.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/GoogleCloudPlatform/container-diff/differs"
2626
pkgutil "github.com/GoogleCloudPlatform/container-diff/pkg/util"
2727
"github.com/golang/glog"
28-
"github.com/pkg/profile"
2928
"github.com/spf13/cobra"
3029
)
3130

@@ -43,9 +42,6 @@ var analyzeCmd = &cobra.Command{
4342
return nil
4443
},
4544
Run: func(cmd *cobra.Command, args []string) {
46-
if os.Getenv(containerDiffEnvPrefix) == "1" {
47-
defer profile.Start(profile.TraceProfile).Stop()
48-
}
4945
if err := analyzeImage(args[0], strings.Split(types, ",")); err != nil {
5046
glog.Error(err)
5147
os.Exit(1)

cmd/diff.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/GoogleCloudPlatform/container-diff/differs"
2727
pkgutil "github.com/GoogleCloudPlatform/container-diff/pkg/util"
2828
"github.com/golang/glog"
29-
"github.com/pkg/profile"
3029
"github.com/spf13/cobra"
3130
)
3231

@@ -44,9 +43,6 @@ var diffCmd = &cobra.Command{
4443
return nil
4544
},
4645
Run: func(cmd *cobra.Command, args []string) {
47-
if os.Getenv(containerDiffEnvPrefix) == "1" {
48-
defer profile.Start(profile.TraceProfile).Stop()
49-
}
5046
if err := diffImages(args[0], args[1], strings.Split(types, ",")); err != nil {
5147
glog.Error(err)
5248
os.Exit(1)

cmd/root.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ type validatefxn func(args []string) error
4141
const (
4242
DaemonPrefix = "daemon://"
4343
RemotePrefix = "remote://"
44-
45-
containerDiffEnvPrefix = "CONTAINER_DIFF_ENABLE_PROFILING"
4644
)
4745

4846
var RootCmd = &cobra.Command{

main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,16 @@ import (
2323

2424
"github.com/GoogleCloudPlatform/container-diff/cmd"
2525
"github.com/golang/glog"
26+
"github.com/pkg/profile"
2627
)
2728

29+
const containerDiffEnvPrefix = "CONTAINER_DIFF_ENABLE_PROFILING"
30+
2831
func main() {
2932
flag.Parse()
33+
if os.Getenv(containerDiffEnvPrefix) == "1" {
34+
defer profile.Start(profile.TraceProfile).Stop()
35+
}
3036
if err := cmd.RootCmd.Execute(); err != nil {
3137
fmt.Println(err)
3238
os.Exit(1)

0 commit comments

Comments
 (0)