| 50 | } |
| 51 | |
| 52 | func ExampleStart_withFlags() { |
| 53 | // use the flags package to selectively enable profiling. |
| 54 | mode := flag.String("profile.mode", "", "enable profiling mode, one of [cpu, mem, mutex, block]") |
| 55 | flag.Parse() |
| 56 | switch *mode { |
| 57 | case "cpu": |
| 58 | defer profile.Start(profile.CPUProfile).Stop() |
| 59 | case "mem": |
| 60 | defer profile.Start(profile.MemProfile).Stop() |
| 61 | case "mutex": |
| 62 | defer profile.Start(profile.MutexProfile).Stop() |
| 63 | case "block": |
| 64 | defer profile.Start(profile.BlockProfile).Stop() |
| 65 | default: |
| 66 | // do nothing |
| 67 | } |
| 68 | } |