NewTimer creates a Timer object within the given stat if stat is non-nil. The value passed in tags will be attached to the newly created Timer. NewTimer also automatically sets the Begin value of the Timer to the current time. The user is expected to call stat.Egress with the returned index as argum
(tags string)
| 155 | // time. The user is expected to call stat.Egress with the returned index as |
| 156 | // argument to mark the end. |
| 157 | func (stat *Stat) NewTimer(tags string) *Timer { |
| 158 | if stat == nil { |
| 159 | return nil |
| 160 | } |
| 161 | |
| 162 | timer := &Timer{ |
| 163 | Tags: tags, |
| 164 | GoID: goid(), |
| 165 | Begin: time.Now(), |
| 166 | } |
| 167 | stat.mu.Lock() |
| 168 | stat.Timers = append(stat.Timers, timer) |
| 169 | stat.mu.Unlock() |
| 170 | return timer |
| 171 | } |
| 172 | |
| 173 | // AppendTimer appends a given Timer object to the internal slice of timers. A |
| 174 | // deep copy of the timer is made (i.e. no reference is retained to this |