TimeTrack determines the amount of time a function takes to return. Timer starts when it is called. The printed name is determined from the calling function. It returns an anonymous function that, when called, will print the elapsed run time. It only tracks if DDEV_VERBOSE is set. Usage: defer u
()
| 29 | // ... |
| 30 | // tracker() |
| 31 | func TimeTrack() func() { |
| 32 | if globalconfig.DdevVerbose { |
| 33 | // Determine name from calling function. |
| 34 | var name string |
| 35 | |
| 36 | if counter, _, _, success := runtime.Caller(1); !success { |
| 37 | name = "<failed to determine caller name>" |
| 38 | } else { |
| 39 | name = runtime.FuncForPC(counter).Name() + "()" |
| 40 | } |
| 41 | |
| 42 | return timeTrack(&name) |
| 43 | } |
| 44 | |
| 45 | return func() {} |
| 46 | } |
| 47 | |
| 48 | // TimeTrackC determines the amount of time a function takes to return. Timer |
| 49 | // starts when it is called. The customName parameter is printed. It returns an |
no test coverage detected