NewTimer creates a new Timer. The provided Observer is used to observe a duration in seconds. If the Observer implements ExemplarObserver, passing exemplar later on will be also supported. Timer is usually used to time a function call in the following way: func TimeMe() { timer := NewTimer(my
(o Observer)
| 42 | // // Do actual work. |
| 43 | // } |
| 44 | func NewTimer(o Observer) *Timer { |
| 45 | return &Timer{ |
| 46 | begin: time.Now(), |
| 47 | observer: o, |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // ObserveDuration records the duration passed since the Timer was created with |
| 52 | // NewTimer. It calls the Observe method of the Observer provided during |
no outgoing calls