StartProfile starts a new mode for profiling.
(conf *viper.Viper)
| 21 | |
| 22 | // StartProfile starts a new mode for profiling. |
| 23 | func StartProfile(conf *viper.Viper) Stopper { |
| 24 | profileMode := conf.GetString("profile_mode") |
| 25 | switch profileMode { |
| 26 | case "cpu": |
| 27 | return profile.Start(profile.CPUProfile) |
| 28 | case "mem": |
| 29 | return profile.Start(profile.MemProfile) |
| 30 | case "mutex": |
| 31 | return profile.Start(profile.MutexProfile) |
| 32 | case "block": |
| 33 | blockRate := conf.GetInt("block_rate") |
| 34 | runtime.SetBlockProfileRate(blockRate) |
| 35 | return profile.Start(profile.BlockProfile) |
| 36 | case "": |
| 37 | // do nothing |
| 38 | return noOpStopper{} |
| 39 | default: |
| 40 | fmt.Printf("Invalid profile mode: %q\n", profileMode) |
| 41 | os.Exit(1) |
| 42 | return noOpStopper{} |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | type noOpStopper struct{} |
| 47 |
no test coverage detected