Skip to content
Snippets Groups Projects
Commit 34e07445 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Add cpu profiling

parent 2b0c3808
No related branches found
No related tags found
1 merge request!23Release
...@@ -46,6 +46,14 @@ var rootCmd = &cobra.Command{ ...@@ -46,6 +46,14 @@ var rootCmd = &cobra.Command{
Short: "Runs a client for cMix anonymous communication platform", Short: "Runs a client for cMix anonymous communication platform",
Args: cobra.NoArgs, Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
profileOut := viper.GetString("profile-cpu")
if profileOut != "" {
f, err := os.Create(profileOut)
if err != nil {
jww.FATAL.Panicf("%+v", err)
}
pprof.StartCPUProfile(f)
}
client := initClient() client := initClient()
...@@ -262,6 +270,10 @@ var rootCmd = &cobra.Command{ ...@@ -262,6 +270,10 @@ var rootCmd = &cobra.Command{
"Failed to cleanly close threads: %+v\n", "Failed to cleanly close threads: %+v\n",
err) err)
} }
if profileOut != "" {
pprof.StopCPUProfile()
}
}, },
} }
...@@ -770,6 +782,10 @@ func init() { ...@@ -770,6 +782,10 @@ func init() {
"", uint(defaultE2EParams.NumRekeys), "", uint(defaultE2EParams.NumRekeys),
"Number of rekeys reserved for rekey operations") "Number of rekeys reserved for rekey operations")
viper.BindPFlag("e2eNumReKeys", rootCmd.Flags().Lookup("e2eNumReKeys")) viper.BindPFlag("e2eNumReKeys", rootCmd.Flags().Lookup("e2eNumReKeys"))
rootCmd.Flags().String("profile-cpu", "",
"Enable cpu profiling to this file")
viper.BindPFlag("profile-cpu", rootCmd.Flags().Lookup("profile-cpu"))
} }
// initConfig reads in config file and ENV variables if set. // initConfig reads in config file and ENV variables if set.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment